HTTP PATCH request generate body from variables

I am trying to configure workflow which calls http patch request. After trigger added a step to read from input params (using Process Requests with JavaScript) but when I am trying to make patch call on the received input params it is giving “No data provided” (means body is sent as empty).

If I replace response[0][“number”] with static number it is working fine. I tried with Any, String and with/without expression options.
Any - with expression - No data provided
Any - without expression - “JSON parse error - Expecting value: line 2 column 13 (char 14)”

Please help.

Hi,

We require more information on the request than what has been provided.

  • Please try setting the variable in an expression and checking the value passed.
  • Send some more details on the ‘js env configuration’. The use of the variable ‘request’ could be incorrect as this is the default Corteza variable and not the output from a wf step, I believe. Please double-check to see if you are using request as the output from the js process, if you are, please change this and try again with the new variable reference.

If you would also provide the full response this should help.

Hello @AndreB , Thank you for your reply.

I have read the input as below and stored in response variable which looks like

response output:

[
    {
        "id": 2,
        "number": "123456",
        "balance": "200.00"
    }
]

I also used expression to store in individual params and tried to use it … but it is showing same result.

Let me know if this info is sufficient.

PS: I can see response[“id”] field is properly being converted which is being used in url field. The issue is with body part.

Hi, Any config change suggestions to resolve this issue. Or is it a bug ?

Hi @asksonu ,

I can try and test your setup, but looking, but iirc, the marshalling of the Any type of field to JSON has some additional meta data.

So best bet for now would be to:

  • stringify the object in the javascript function already
  • return resultAny as type String (or name it resultString to avoid confusion)
  • use the string as body in PATCH

Let us know how it goes, cheers

Thank you @peter … It is working this way …
thanks again.