I am using http request activity in which I have to pass 2 variables in Json Body and then pass the same Json in Body (Properties options in HTTP Request activity). 1st variable(Request ID) is working fine but I am getting below error for 2nd variable(Transaction ID). I am also providing the complete Json body and their output along with error.
Error:
{“fault”:{“faultstring”:“JSONThreatProtection[JSON-Threat-Protection-1]: Execution failed. reason: Expected STRING or NUMBER or OBJECT or ARRAY at line 13”,“detail”:{“errorcode”:“steps.jsonthreatprotection.ExecutionFailed”}}}
@ashokkarale , Thanks for your response
Hardcoded value is working fine but in my case I have to use dynamic transaction ID value. Please find below hardcoded sample json body which is working absolutely fine.
The best approach here is to use a txt file to have your JSON body template, read the txt file, replace the value with a dynamic variable, and pass it to the HTTP Request.
jsonbody.txt
{“name”:“John”, “ID”:“vID”}
vID - is the placeholder
In code, read the jsonbody.txt, store it as strJsonBody, and replace the values like
The problem with this approach is you are missing the quotations for the string variable value. To have clear structure and ease of use, go with the approach I mentioned.
““TransactionID””:“”“+TransactionID.ToString+”“”
You can use asset also instead of txt file if you prefer.
This requires the latest Studio and System activity package, but the principle behind is the new JSON Sample property of the Deserialize JSON activity. It allows you to “generate” the actual usable object based on your JSON sample, and then to simply assign your desired values to its properties.
After you are done, you simply convert it back to a string and you have your input.
One thing to keep in mind is that you need to match your API’s requirement, so it could either be this: