Hi folks, I’m trying to emulate the behavior of Ruby’s encode_www_form in a pre-release script. (If there’s a quick way to do this, I’d appreciate that, but otherwise, this is the issue I’m currently facing:)
pm.request.body.urlencoded is a PropertyList. It even says so in Postman when I hover over it.
When I try any methods on it (e.g. map) it says that PropertyList is not defined. Do I need to import it somehow? Here is a public workspace showing the issue:
Thanks Danny, this works! Is the dot notation after the require something that’s Postman-specific or is this a common language feature?
At the moment, I’m trying to URI encode the keys/values from a form body and join them back up with &. When I used encodeURI or encodeURIComponent, it also transformed the & which wasn’t what I needed. Accessing the property list means I can map the entries into the format I need:
It’s a common language feature and it allows you to access a function inside the object. I’m not even going to pretend like I know this topic inside out, I really don’t but I know you can do that.
In terms of the Postman Sandbox, if you remove the .PropertyList and then added a . again, you’d be shown the other functions.