How to place a multi-line single string JSON in POSTMAN?
Postman has a "graphql" type of request body. It means you can write your query without quotes (see screenshot attached). Also, it is useful when you are assigning variables to query/mutation.
P.S. you might need to update your postman to get a "graphql" type of body payload.
Apparently you can't, therefore you need to turn your multiline string into a single string.
Quickest way to do this is to paste it in a web browser search bar for a format change, then copy and paste from the web browser search bar back into postman.
If you're trying to enter the query into body of your post request in the postman app, a quick workaround to achieve multiple lines is to use a placeholder in the form of an environment variable in your body and enter the query in your pre-request script:
In your body:
{
"query":{{query}}
}
In your pre-request script:
pm.environment.set("query", JSON.stringify(
`
query {
organization(login: "MY-ORG-ID") {
samlIdentityProvider {
externalIdentities(first: 10) {
edges {
node {
user {login}
samlIdentity {nameId}
scimIdentity {username}
}
}
}
}
}
}
`
));
Note that ` in the above code is a backtick, not a single quote!
It's not the best solution ever, but the only one that worked for me so far in Postman to avoid entering more complex queries/mutations in a single line.
Hope this helps.