Hello,
I have an online application that I can request data extractions from by submitting an HTTP request with the appropriate JSON fields.
One field (field2) within my JSON payload is a list type and can contain one or more items. The issue that I am facing is that my JMP script functions only if this list has a single item and not if it has two or more.
The error that I receive is:
"error":"com.google.gson.stream.MalformedJsonException: Unterminated string
What confuses me is that if I make the same HTTP request with the same JSON payload using Python's request library, the request goes through without an issue.
It seems like it may have to do with how JMP is formatting the JSON before it sends the request out.
Any ideas?
Below is a simplified version of my code for reference.
url = "http://www.example_url.com/request";
my_username = "username";
timeout_minutes = 2;
var_field1 = "\!"value1\!"";
var_field2 = "\!"value2a\!""; //works
//var_field2 = "\!"value2a\!", \!"value2b\!""; //does not work
var_field3 = "\!"value3\!"";
payloadJSON = "{\!"test\!":{\!"field1\!":" || var_field1 || ",\!"field2\!":[" || var_field2 || "],\!"field3\!":[" || var_field3 || "]}}";
request = New HTTP Request(
URL( url ),
Method( "POST" ),
Timeout(timeout_minutes*60),
Headers
(
{
"header_field1": "header_value1",
"header_field2": "header_value2"
}
),
Username(my_username),
JSON(payloadJSON)
);
data = request << Send();