Post

1 follower Follow
0
Avatar

API returning incorrect User ID

Using the REST API to get a User ID - for some users it works, for other users it returns nonsense.

e.g.

User/51hbo7p6f5c4xbl89kpwujr1e1983 is fine

but

User/142135553 returns as User/2017-05-24 00:00:00
User/142135617 returns as /User/1.22222222

It seems like alphanumeric user ids are okay, but numeric-only ids cause issues?

I am using Google Scripts for my API:

function getClarizenUser(email) {
  var data = {
    "typeName": "User",
    "fields": [
      "Email",
      "JobTitle"
    ],
    "where": {
        "leftExpression": {"fieldName": "Email"},
        "operator": "Equal",
        "rightExpression": {"value": email}
    }
  };
  var options = {
             "method": "post",
             "contentType": "application/json",
             "headers":{
                        "Authorization": API_KEY
                      },
                "payload": JSON.stringify(data)
             };
  var response = UrlFetchApp.fetch(url, options);
  var text = response.getResponseCode();
  Logger.log(response.toString());
  var obb = JSON.parse(response);
  Logger.log(text);
  return obb.entities[0].id;
}

 

Michael Hitchcock

Please sign in to leave a comment.