i need to send a nested array through $_GET or $_POST. i can’t seem to figure out how to enter the data in the variable section. here’s a screenshot of what i have:
so how do i enter the array elements properly so they are recognized as an array and not a string. because that borks the code that relies on it being an array…
It looks like you are drying to make each array entry and object. I can’t see the whole thing, but I recommend trying {“id”:132421,“reportId”:“2927483”,"dCode:“EP0ee309”} --that would be value JSON for each directive array entry. Hope that helps.
nope. still not working. i don’t know how to make this any clearer. i need a nested array. needs to look like this, because this is what the webapp itself is actually sending through $_GET/$_POST:
i hope this helps understand what i need a bit better. if not, please let me know. because if i’m stuck using one dimensional arrays, then this whole app is useless… and i doubt that’s the case. so i’m just needing to know how to give what it needs to do the job.
“pre-request script”… that’s what i need because the other way is flat out torture. is it something you can illustrate quickly, or do i need to spend an afternoon researching it on the website?
EDIT: found the ‘tutorial’. useless. have no idea what how the hell i’d send an array with it. at least i have a toe-hold. thank you.
whoa. that’s a hell of a lot of code to just import a nested array! thank you for taking time out of your day to do that for me! O_o where did you find the info to build that thing? i couldn’t find anything of depth or use on the website.
The issue is that Node.js doesn’t stringify nested arrays/objects the same way PHP does. So there’s a dozen lines of code or so to do that.
We could lighten the weight of the code a bit, but it requires pulling in another Node.js module, qs. Pulling in external modules can add a layer of complexity, so I try to solve issues with built-in functionality first. (See this template: Browserify CDN modules.)
Here’s what the code would look like with the qs module:
new Function(pm.variables.get('init'))(pm);
const obj = {
buildingName: "Palace of Doom",
directives: [
{
id: 132421,
reportID: "2927483",
dCode: "EP0ss309",
dInfo: "keep dry and free of water",
dDue: "2020-05-14"
},
{
id: 132421,
reportID: "2927483",
dCode: "EP0ss309",
dInfo: "keep dry and free of water",
dDue: "2020-05-14"
},
]
};
const qs = require('qs');
pm.request.addQueryParams(qs.stringify(obj));
gotcha. as much as i bitch and moan about this, i do appreciate your help learning this tool. long day and frustration has me tetchy and looking for simple solutions… so thanks again for your patient instruction. just when i think i know a tool… oh look. more. my biggest concern now, is where to find this information because, as i mentioned earlier, i found none of this on the website.