Hello! Good day to everyone. I need your expertise on this json script. I’m trying to import this in POSTMAN but I’m having the Incorrect format error. This is the script for your reference. I appreciate your help on this. Thanks!!!
var myHeaders = new Headers();
var formdata = new FormData();
formdata.append("accname", "testAccount");
formdata.append("api_key", "API_KEY_123");
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: formdata,
redirect: 'follow'
};
fetch("https://pro.dat.com/safpi/", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The import feature only allows specific formats to be used, Collections, Environments, API Specs, etc.
Your example looks like a fetch script, you would need to manually enter that into the request builder.
If you were to get the same request in cURL format, you could paste that directly into the URL address bar and it will populate those various parts of the request.
That looks like a straight forward request that you would setup using the Postman GUI.
Should take all of 2 minutes?
It only looks like you are setting two form data key\value pairs, and although it has code for headers, it doesn’t look like its adding any extra headers (so can probably be ignored).
If you are new to Postman, then I would suggest a visit to the Learning Centre.
Including the Postman Training links under “Other Resources”.
I would recommend the “Galaxy APIs 101” course first as it gets you used to the application features.
Then the “Galaxy Testing and Automation” course which teaches you how to assert the responses. It includes defining and using variables from responses.