Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If query fields are important to your API (which is likely since you need to allow them to be accepted in the first place) you'll want to retrieve the value of each query field. This could be done by parsing the full URL yourself (which is automatically stored in the FullEndpointURL variable). However, we recommend you use the GetQueryField service (which is a member of the HTTP_Services module). Here is what our code might look like:

...

While query fields and request header fields must conform to the patterns noted in the HTTP specification, parameters in the request body are always developer-defined and must be documented carefully. It is impossible to cover every possible possible response body format, but since this is an article focused upon APIs designed with the SRP HTTP Framework, it is probably safe to assume that the format will be JSON (e.g., {"status" : "active"}) or XML (e.g., <status>active</status>). Regardless of the format, use the GetHTTPValue service to retrieve the content of the body.

If the response body is formatted as JSON, we recommend using the SRP_JSON library to parse and retrieve the parameter value:

Code Block
languagebp
Body    = HTTP_Services('GetHTTPPostString')
If SRP_JSON(objBody, 'Parse', Body) EQ '' then
    CustStatus  = SRP_JSON(objBody, 'GetValue', 'status')
    SRP_JSON(objBody, 'Release')
end