Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Using the JSON interface

The easiest way to start learning about this interface is to try it out. This section shows how to use the curl command line tool to execute sample queries.

NOTE: Details about each API and the available commands are available in separate documents for each individual API

Sample JSON Requests
 Attach this curl command to the beginning of any of the below sample requests:

	curl -i -H "Accept: application/json"


 People API

	https://iet-ws-test.ucdavis.edu/api/iam/people/search?firstName=Gary&lastName=Sharpe&key=myKeyv&v=1.0


 DisplayName API

	https://iet-ws-test.ucdavis.edu/api/iam/people/displayname/{iamid}?key=myKeyv&v=1.0


 SystemIds API

	https://iet-ws-test.ucdavis.edu/api/iam/people/systemids/{iamid}?key=myKeyv&v=1.0
	https://iet-ws-test.ucdavis.edu/api/iam/people/systemids/search?mothraId=1111111&key=myKeyv&v=1.0


 Affiliations API

	https://iet-ws-test.ucdavis.edu/api/iam/people/affiliations/{iamid}?key=myKeyv&v=1.0
	https://iet-ws-test.ucdavis.edu/api/iam/people/affiliations/isfaculty?key=myKeyv&v=1.0



 PriKerberosAccount

	https://iet-ws-test.ucdavis.edu/api/iam/people/prikerbacct/{iamid}&key=myKeyv&v=1.0



The response to all of the above requests have a Content-Type of text/javascript.  An example response for the the following request is shown below:

Sample JSON Request and accompanying Response
curl -i -H "Accept: application/json" https://iet-ws-test.ucdavis.edu/api/iam/people/search?firstName=Gary&lastName=Sharpe&key=myKeyv&v=1.0





{
  "responseData" : {
    "results" : [
{
"IAMId": "",
"mothraId": "",
"PPSId" : "",
"studentId": "",
"bannerPIdM": "",
"externalId": "",
"offFirstName" : "",
"offMiddleName": "",
"offLastName": "",
"offSuffix" : "",
"offFullName": "",
"disFirstName" : "",
"disMiddleName": "",
"disLastName": "",
"disSuffix" : "",
"disFullName": "",
"isFaculty": "",
"isStudent": "",
"isStaff": ""
"privacyCode": "",
"modifyDate": "",


},
{ ...<More results>.... }
 ],
  "responseDetails" : null,
  "responseStatus" : 0
}

JSON reference

Unlike the core JavaScript interface, the JSON interface is exposed through a uniform URL that contains CGI arguments. Your application can use an HTTP stack of its choosing. In order to use the JSON interface:

  • You must construct a properly formatted URL with all necessary CGI arguments.
  • You must send an HTTP referer header that accurately identifies your application.
  • You must process the JSON-encoded response.

Request format

URL base address

The base URL for the IAM Identity Store People APIs all start with http://iet-ws.ucdavis.edu/api/people.  The details of each API are provided in documentation about each individual API.  (See links above)

URL arguments

This section provides examples of the kinds of arguments that can be used with the People APIs

The value of a CGI argument must always be properly escaped. This can be done via the functional equivalent of JavaScript's encodeURIComponent() method.

Required URL arguments

The following table lists the required URL arguments.

Argument

Example

Description

key

key=your-key

This argument supplies the application's key. You can sign up for an API key <INSERT LINK HERE>.
It must be a valid key associated with your application. The key is required for this API to implement quality of service rules for this API. If your application is making too many requests it will be throttled to ensure resources are not overloaded during times of peak usage. Also, by supplying a key we can identify and contact you should something go wrong with your application.

v

v=1.0

This argument supplies protocol version number. The only valid value at this point in time is 1.0.

Search URL arguments

The following table lists the possible search query URL arguments. At least one argument should be provided to perform a search. If multiple search criteria are provided an 'AND' search will be performed to match on all arguments.

Wildcard Searches: Any argument may use a wildcard within the query value. You may use multiple wildcards in any position in the search criteria. See examples below.*

Example search arguments:

Search for anyone with last name of 'Bray'
/api/directory/search?sn=Bray&key=myKeyv&v=1.0
Search for anyone with first name of 'Curtis' and last name starting with 'B'
/api/directory/search?givenName=Curtis&sn=B*&key=myKeyv&v=1.0
Search for anyone with a displayName that starts with 'J' and ends with 'Jones'
/api/directory/search?displayName=J*Jones&key=myKey&v=1.0
Response format

Each response follow this general format:

{
  "responseData" : {
    "results" : []
  },
  "responseDetails" : null | string-on-error,
  "responseStatus" : 0 | error-code
}

In the JSON fragment above, note that the responseData property contains a results array and an optional cursor.

Trouble shooting

If you encounter problems with your code:

  • Make sure your API key is valid.
  • Look for typos. Remember that JavaScript is a case-sensitive language.
  • Use a JavaScript debugger. In Firefox, you can use the JavaScript console or the Firebug. In IE, you can use the Microsoft Script Debugger.
  • If you need to examine the JSON string returned from the server, you can use JSON Lint to make a single, long string human readable.
  • Email middleware-api@ucdavis.edu with a description of your problem and a trace of the request and response.
  • No labels