Questions on WEB API Object

Hi,

Need help on below. Could someone please help me?

I have few questions on Web API objects:

  1. Can I use query parameters in Post method? In what scenario?
  2. Where can we use Query Parameters as well as body in Post method?
  3. When I am trying to update one field model by passing body as

{"id":1,

"model":"Jaguar"},

 

It is updating all the fields and except id and model all other fields are updated with null.

How can I update only “model” field?

 

Thanks

Faisal

  Discussion posts and replies are publicly visible

Parents Reply Children
  • Hi Danny,

    Thank you for the answers. I am clear about first and second questions.

    I will rephrase my second question.

    In a same web API object creation can  Query parameters and Body both be used? if yes, in what scenario?

    If no, it means at a time only one thing either Query Parameter or Body can be used. Kindly correct me if this is a wrong understanding.

    Thanks

    Faisal

  • Sure you can use both query parameters and body in a POST. Like Danny said, you can reference both of them using the http! domain. The main thing to make sure is that whatever system you're making the request from adds the parameters in a way that you can use it. Here's an example of how you can pull both the query parameters and body to start a process based on the details from the request:

    a!localVariables(
      local!queryParameters: http!request.queryParameters,
      local!body a!fromJson(
        http!request.body
      ),
      a!startProcess(
        processModel: cons!MY_PROCESS_MODEL,
        processParameters: {
          queryParameters: local!queryParameters,
          body: local!body
        },
        onSuccess: a!httpResponse(
          statusCode: 200,
          headers: {
            a!httpHeader(name: "Content-Type", value: "application/json")
          },
          body: a!toJson(
            fv!processInfo
          )
        ),
        onError: a!httpResponse(
          statusCode: 500,
          headers: {
            a!httpHeader(name: "Content-Type", value: "application/json")
          },
          body: a!toJson(
            {
              error: "There was an error starting the process"
            }
          )
        )
      )
    )