GraphQL Request - pm.response.json is not a function

Hello, guys, I am now testing GraphQL API, and the same as restful API, I want to save the token and set it to variable.

But when I use the “let response = pm.response.json();”, an error occurs,

“pm.response.json is not a function”.

This happens only when I use the GraphQL basics template to send the request. If I use the regular way : new collection→Add a request… this error will not occur. I do not know where is wrong.

Anybody met this error before? Thx~

Hey @jiapei666 :wave:

Welcome to the Postman Community! :postman:

When using the GraphQL request, the sandbox syntax is slightly different:

You can use pm.response.data to get the response body data:

let response = pm.response.data

We’re working on updating the learning center to reflect this for GraphQL but this would be similar if you were making gRPC requests too:

1 Like

Thank u for your quick reply~ @danny-dainton

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