I have a post method, and I need to pass a variable there.
Once I am trying to do that - I receive code 400.
The Test Json without variable that receives code 200 is ( in one line):
“{ ““appUserName””: ““username””, ““fileExt””: ““txt””, ““fileBase64"”: ““dGVzdDM=””, ““fieldsKeyValue””: { ““company””:”“07"”, ““insuree_id””:”“11581642"”, ““policy_num””:““600015977"”, ““doc_type””:”“902"”, ““doc_date””:““01/01/2019"” }}”
When I try to paste a variable there - i receive code 400. It looks like this:
“{ ““appUserName””: “+ Variable1+”, ““fileExt””: ““txt””, ““fileBase64"”: ““dGVzdDM=””, ““fieldsKeyValue””: { ““company””:”“07"”, ““insuree_id””:”“11581642"”, ““policy_num””:““600015977"”, ““doc_type””:”“902"”, ““doc_date””:““01/01/2019"” }}”
I searched through many topics on the forum, but have not found out.
I took two ways of syntax from here:
The same request with single quotes retrieves code 400:
“{ ‘appUserName’: ‘username’, ‘fileExt’: ‘txt’, ‘fileBase64’: ‘dGVzdDM=’, ‘fieldsKeyValue’: { ‘company’:‘07’, ‘insuree_id’:‘11581642’, ‘policy_num’:‘600015977’, ‘doc_type’:‘902’, ‘doc_date’:‘01/01/2019’ }}”
There is no error in expression editor. If I do as you mentioned above, the variable “AppUserName” is not recognized as variable, but as hardcoded string.
Try reading the JSON code from a text file but use a key(like XXVarXX) where the variable will go, then use stingreplace to replace the XXVARXX with your string variable.
I tried what you offered, but I receive again - code 400. Even if send the same variable, which was hardcoded before.
In case it is hardcoded - i receive code 200 - Ok.
In case of variable - receive code 400.
I would have to defer to someone more familiar with your use case, but would double check you syntax outside of the program to make sure your script has no errors. Perhaps share your script for us to see and redact the sensitive material-leaving the punctuation.
There are my Json syntax:
“{ ‘appUserName’: ‘imageTest’ }” - hardcoded one - doesn’t work
“{ ““appUserName””: ““imageTest””}” - hardcoded one -yes works
“{ ““appUserName””: “+VAR+”}” - not hardcoded and doesn’t work.
I need to make it work with variable.
The problem was in particular this API server. According to its syntax, it accepted the request with triple quot like: “{ ““appUserName””: ““”+VAR+”“”}”
Thanks to UiPath support team.