AgileApps Support Wiki Pre Release

Difference between revisions of "Specifying Query Parameters in REST APIs"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 15: Line 15:


In some cases, it may be necessary to [http://www.blooberry.com/indexdot/html/topics/urlencoding.htm encode special characters] in order to include them in an argument value. For example:
In some cases, it may be necessary to [http://www.blooberry.com/indexdot/html/topics/urlencoding.htm encode special characters] in order to include them in an argument value. For example:
:{|
:{| border="1" cellpadding="5" cellspacing="1"
! Instead of !! Use  
! Instead of !! align="left"| Use  
|-
|-
| & (A&B) || %26 (A%26B)
| & (A&B) || %26 (A%26B)

Revision as of 18:58, 14 September 2011

Specifying Request Arguments

In a REST request, you pass arguments in the form of query parameters. Those parameters are specified in the form parameterName=value.

A parameter list is appended to a URI after a "?". Multiple parameters are separated by "&", as shown here:

<syntaxhighlight lang="vbnet">
 http://{domain}/{address}?parameterName1=value1&parameterName2=value2

</syntaxhighlight>

For example:

<syntaxhighlight lang="vbnet">
 http://myLongJump.com/networking/rest/user?fieldList=*&sortBy=first_name

</syntaxhighlight>

For boolean arguments, the value passed can be "1" or "true", "0" or "false".

In some cases, it may be necessary to encode special characters in order to include them in an argument value. For example:

Instead of Use
& (A&B) %26 (A%26B)
space (A B) %32 (A%32B)

Specifying Response Format

You specify the response format as either XML (the default) or JSON, using the alt parameter:

  • ?alt=xml
  • ?alt=json
Example
<syntaxhighlight lang="vbnet">
 http://{domain}/{address}?alt=json

</syntaxhighlight>