Trouble getting data with GraphQL / OAuth2 API

I’m trying to add Jobber’s API (getjobber.com) to my bubble app using the API Connector. This is my first API i’ve tried integrating. From what I can tell is Jobber uses GraphQL and OAuth2 for its API. Here are the docs from jobber (https://developer.getjobber.com/docs)

I think I’ve been able to get an access token and refresh token. When I try to retrieve data using the POST I get the following response:

{
"data": null,
"errors": [
    {
        "message": "The field clients on an object of type Query was hidden due to permissions",
        "locations": [
            {
                "line": 1,
                "column": 9
            }
        ],
        "path": [
            "clients"
        ]
    }
]

}

Here is the query that I entered and works in the GraphiQL on Jobber:

{“query”: “query { clients { totalCount } }”}

Please help! I’m losing my mind trying to figure out what is wrong. Appreciate any direction you guys can provide.

Thanks!

A screenshot of your API connector set up itself would help

Thanks dev86, I actually ended up figuring it out. Jobber was looking for a version code as part of the POST call.

I’m afraid I’m stuck in the same spot. API Connector looks good on the OAuth Post Call. I am Initializing the first call and receiving an access_token in return. I am pasting that access_token in my Value settings for the Authorization header, prepending with 'Bearer ’

When I run JSON query, I am getting a 500 Internal Server Error

Screen Shot 2024-07-22 at 9.32.32 PM|690x279

Here are my API settings:

Help?

Bubble doesn’t work very well with graphQL, it’s really frustrating. I’ve had success by (depending on API):

  • Adding the header Content-Type: application/graphql which more or less let’s you write queries as normal where it works
  • Failing that, instead change that header to Content-Type: application/json then remove all newlines from your body. When using this method, you’ll have to wrap the entire query in another query as in OP’s post:
    {"query": "query { clients { totalCount } }"}

Note also that with the second option, since you are double wrapping the query, any special characters within the nested query will need to be escaped.

What you are sending is not a JSON,

Do you have link to documentation? Maybe you will need to use “raw” as body type and set your content-type header like @ed19 said.

Here are the docs: https://developer.getjobber.com/docs

I’ll try using RAW as the body type and add the header that @ed19 mentioned.

Thanks!

If you look at documentation here: https://developer.getjobber.com/docs/using_jobbers_api/api_queries_and_mutations/
you will see that the API only accept application/json

Like @ed19 said, the query is a string and should give you something like this

{
    "query": "query SampleQuery {clients {nodes {id        firstName        lastName        billingAddress {          city        }      }      totalCount    }  }",
    "operationName": "SampleQuery"
}

According to documentation.
If you keep new line, you will get an error because this will broke the JSON. However, this is possible to keep new line if you encode the query correctly.

{
    "query": "query SampleQuery {\n    clients {\n      nodes {\n        id\n        firstName\n        lastName\n        billingAddress {\n          city\n        }\n      }\n      totalCount\n    }\n  }",
    "operationName": "SampleQuery"
}