Unable to import postman collection into Azure

I imported postman collection to Azure through custom connectors for Azure Logic Apps. However, all the collection variables and pre-request scripts I created on postman do not work as expected. The results I was able to get in postman I cannot get on Azure.
For one of the API calls to BaseURL/get-alert/{{alertIDnow}}/
The collection variable alertIDnow is fetched correctly in Postman but fails in Azure.
Any advice or guidance on how I can approach this?
Thank you so much.

Hey @anchalsingh12 :wave:

Can you check to see if the Collection variables are in both the initial and current values? If these were only in the current value, those variable values wouldn’t have been exported.

Hi Danny,
Thank you for replying.

As the scripts automatically fill the collected variable values only current values are filled in. Any recommendation on how I can get them to fill in initial values the exact same way?

An easy solution?
Here are my scripts:
Script for 1st API:

a = JSON.parse(responseBody)
pm.collectionVariables.set("ID", a);

Script for 2nd API:

const ID = pm.collectionVariables.get("ID")
pm.collectionVariables.set("alertIDnow", ID.shift());
console.log(pm.collectionVariables.get("alertIDnow"));

Is there a simple way to do it? I know there is a way to setup with environment variables and call them but that might break my flow as I’m only exporting postman collection in azure.

Are there variables set at the Collection level before you export them or does that only set them at runtime?

What’s the start state of ID? Is the response body just an array?

Why don’t the just use pm.response.json() to capture the response body, where did you see that you need to use JSON.parse(responseBody)?

The collection variables ID and alertIDnow are both set at runtime.
ID variable is first set after the execution of the first script automatically, and is a list of alert IDs. It is later called and modified in the second script. AlertIDnow variable is created during the execution of the second script.

The response body of the first script is Array I believe. Please see the screenshot below of the response body

I have made the advice response body changes in the code. Please see below the complete scripts for both API calls in the collection.
API 1
Get URL/alerts/alerts-list
tests script

a = pm.response.json()
console.log(a)
pm.collectionVariables.set("ID", a);

API 2
Get URL/alerts/get-alert/{{alertIDnow}}/
pre-request script

console.log(pm.collectionVariables.get("ID"));
const ID = pm.collectionVariables.get("ID")
console.log(ID);
pm.collectionVariables.set("alertIDnow", ID.shift());
console.log(ID);
console.log(pm.collectionVariables.get("alertIDnow"));
if (Array.isArray(ID) && ID.length > 0) {
    postman.setNextRequest('detail');
    pm.collectionVariables.set('ID', ID); 
    console.log(pm.collectionVariables.get('ID'))
    }
else {
    postman.setNextRequest(null)
}

Hope this answers your question. Thank you for the help.

Hi team,
following up on my previous message. Is there a simple way to update my initial values in the same way current values are being updated for collection variables during runtime?

I want to avoid doing this through environment variables as I will be exporting postman collection to Azure so it might not pick the environment variables.

Any help or advice?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.