- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 01:43 PM
I am attempting to populate a nested JSON object via JavaScript.
I'm pretty comfortable with setting up JSON Parameters that are not nested.
r.setStringParameter('field_name', value);
{
"field_name":"value"
}
But how would I set up my scripted REST call to populate the following nested values:
{
"fields": {
"project":
{
"key": "How do I set this?" // This value
},
"summary": "How do I set this?",
"description": "How do I set this?",
"issuetype": {
"id": "How do I set this?"
}
}
}
In the above example, how would I populate "key"?
Setting r.setStringParameter() of all the following have failed:
r.setStringParameter(fields.project.key, 'value');
r.setStringParameter(key, 'value');
Is the JSON Content field on the REST Message itself the only way to go about doing this? What happens if I set a string parameter via script but I have a JSON attribute hard coded?
Thanks!
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 01:49 PM
Here is how you can pass the object
var obj = {};
obj.key = 'value';
r.setStringParameter('project', obj);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 01:47 PM
You can do that by
var myJSON = {
};
myJSON.fields.project.key ="How do I set this?";
mySoap.setRequestBody(JSON.stringify(myJSON));
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2019 01:49 PM
Here is how you can pass the object
var obj = {};
obj.key = 'value';
r.setStringParameter('project', obj);