read values from external json data file in postman - postman

In my external jsondata file, i have defined “external” : null and I am calling that attribute in my post request body as “external”:{{external}} but acutally the “null”” value is not called. In the request body the value shows as “external”:{{external}} instead of “external”: null. please help me

https://github.com/postmanlabs/postman-app-support/issues/9606
It looks like a issue have raised above ticket , but as a work around use the below line of code in your pre-request code:
data["external"]===null?pm.variables.set("external",null):undefined
Here we are setting the value to null explicitly to null in local variable scope

Related

pm.request.url.toString() with value of env var instead of the placeholder

If request is using an environment variable then when using pm.request.url.toString() inside a Pre-requisite Script it outputs the query with the placeholder and not it's actual value.
meaning it will output https://somesite.com/api/v3/{{env_variable}} instead of https://somesite.com/api/v3/liststuff or whatever.
Is there anyway to get the URL with the value and not the placeholder?
Request is not resolved in the pre-request script since the variables could be further modified there.
But you can use the postman-collection library within the scripts to resolve the request yourself.
Thanks harryi3t for posting this script on GitHub
https://github.com/postmanlabs/postman-app-support/issues/3322
Here's a sample script
let sdk = require('postman-collection'),
newRequest = new sdk.Request(pm.request.toJSON()),
resolvedRequest = newRequest.toObjectResolved(null, [pm.variables.toObject()], { ignoreOwnVariables: true });
// prints the resolved request to console. Please check DevTools to see the structure
console.log({ resolvedRequest });
Kindly refer screenshot for the same in which custId takes value from placeholder and resolved in pre request also before excuting actual request

iterator was not set on data decoded from API

so I'm at lost of why this happened. I keep receiving error in console log that says The getter 'iterator' was called on null .
What I'm sure of:
I know this is not the case because the data returned from api is there.
The decoded data is also there.
And the view renders the data perfectly fine, so the data is obviously there.
But the error keeps on popping it's like, the decoded data decoded
from JSON turned to map then list is missing of iterator attribute.
Can someone help me on this ?
This is the code and the error showed by dart debugger.Thanks.
Here is the response.body of the api call. So yeah the data is there. Sorry about the red highlight since i can't show you the content.
Try modifying the request initialization to
List<Dynamic> request = new List() ;
And remove the cast as List<dynamic >;

findRecord() returns error but record is returned properly

I have a strange error when calling data store's findRecord() function. Below is the function call inside of a route,
return this.get('store').findRecord('restaurant', params.restaurant_id);
And here are the errors I get,
vendor-6605726….js:10 Error while processing route: admin.restaurants.show e.getRecord is not a function TypeError: e.getRecord is not a function
vendor-6605726….js:8 TypeError: e.getRecord is not a function
The strangest thing is that the function works as it should since I can see using ember inspector that the query executes properly and returns the correct record. I have an index route that calls findAll() that does not throw any errors. I am formatting my json correctly I believe so I am out of ideas on what this could me.
Here is the json,
{"data":[{"type":"restaurants","id":1,"attributes":{"user_id":1,"name":"###########","address":"","phone":"##########","website":"##########","created_at":"2017-03-19 20:42:02","updated_at":"2017-03-19 20:42:02","description":"###########"}}]}
I recently had the same issue. It is highly likely that the JSON payload returned by your API isn't formatted correctly. Remember that findRecord() expects a single object to be returned, not an array:
{"data": {}}
not
{"data": []}
Double-check DevTools to see what your API returns to the client - make sure it's not an array.

the persisting records instructions in the guide don't work for me

I'm trying to use the instructions find here:
http://emberjs.com/guides/models/persisting-records/
My server receives the json well and creates a record which it then returns properly, but my onSuccess function doesn't get anything usable as a response. It gets this strange object which if I try to pass onto the next route like the instructions say, it errors out saying this:
Uncaught Error: Assertion Failed: The value that #each loops over must be an Array. You passed '' (wrapped in (generated articles.view controller))
Here is my code:
https://github.com/mgenev/Full-Stack-JS-Boilerplate/blob/master/public/ember/controllers/articles_controller.js
I appreciate any help.
It looks like your transitionToArticle function requires an argument but you're not passing in anything when you're calling it:
article.save().then(transitionToArticle).catch(failure);

Structure Saved in a Session Variable

The ReportInfo is a structure. The structure works fine on one web page but I am trying to use it on another web-page. Here is where I saved the ReportInfo structure to the Session Variable
Session["ReportInfo"] = reportInfo;
On the other web-page, I re-created the Structure and then assign the session variable to it, like this...
reportInfo = (ReportInfo)(Session["ReportInfo"]);
I get the following run-time error:
System.InvalidCastException was unhandled by user code
Message="Specified cast is not valid."
Source="App_Web_-s8b_dtf"
How do I get the ReportInfo structure out of the Session variable to use again?
Have you checked the value of Session["ReportInfo"]? Perhaps it's null or some other unsavory value? Also, I assume reportInfo in the second page is of type ReportInfo?