Versions Compared

Key

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

...

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 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 and media type, so we'll focus on the two most likely cases: JSON (e.g., {"status" : "active"}) or and XML (e.g., <status>active</status>). Regardless of the formatmedia type, use the GetHTTPValue service to retrieve the content of the body and then parse the data with the best tools available.

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

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

For an XML formatted response body, we recommend use the SRP_Extract_XML library. Again, here is a simple example:

Code Block
languagebp
Body        = HTTP_Services('GetHTTPPostString')
CustStatus  = SRP_Extract_XML(Body, 'status/text()')