Custom app query with 400 error. Graphql request with getjobber.com

I am trying to set up a simple select query in a module and am getting an error 400. This is my first custom app with getjobber.com. The connection seems to be working fine. Below is the communication section. Any ideas where I am going wrong?

{
    "url": "/graphql", // Endpoint for GraphQL
    "method": "POST",  // Use POST for GraphQL queries
    "headers": {
        "X-JOBBER-GRAPHQL-VERSION": "2023-08-18", // Header for specifying GraphQL version
        "Content-Type": "application/json"       // Set Content-Type for JSON
    },
"body": {
  "query": "query selectvisits1 { visits(sort: {direction: ASCENDING, key: CLIENT_PRIMARY_NAME}, last: 3, filter: {startAt: {after: \"{{parameters.visitDate}}\", before: \"{{parameters.beforeDate}}\"}}) { totalCount }}"
},
    "type": "raw", // Set the body type to raw

    "response": {
        "output": "{{body}}" // Return JSON response body as an output bundle
    }
}

Can you provide a link to the getjobber developer API documentation?

Can you describe what you are trying to do with that query?

2 Likes

Here is the documentation.

I am trying to do a simply query in the module. I have done the same query with success in an HTTP make an auth2.0 request module. See below.

        "ca": null,
        "qs": [],
        "url": "https://api.getjobber.com/api/graphql",
        "data": "{\n  \"query\": \"query selectvisits1 { visits(sort: {direction: ASCENDING, key: CLIENT_PRIMARY_NAME}, last: 3, filter: {startAt: {after: \\\"2024-01-17\\\", before: \\\"2024-01-18\\\"}}) { totalCount }}\"\n}",
        "gzip": true,
        "method": "post",
        "headers": [
            {
                "name": "X-JOBBER-GRAPHQL-VERSION",
                "value": "2023-08-18"
            }

Hi Shawn,

Did you try changing the type from "type": "raw" to "type": "json" ?

3 Likes

This won’t work, as GraphQL queries are not JSON.

2 Likes

I just tried and am getting the same 400 error.

It turns out the issue was in a few areas:

@Thomas_Gaillard was correct: "type": "json", allowed the query to pass so we could see the query in the dev tool.

In the connection parameters we needed to specify differently how the token expires:
"expires": "{{addSeconds(now, 3300)}}",

There was a missing “api” in the token refresh url.
"url": "https://api.getjobber.com/api/oauth/token"

Thank you @Thomas_Gaillard for persisting with your help via dm. Really appreciated.

3 Likes

Heya @Shawn :wave:

It’s great to hear that you managed to get this up and running with the expert assistance of @Thomas_Gaillard :muscle:

Thank you very much for jumping back in here and sharing a summary of what the issue was + how you managed to solve it. This could be incredibly helpful to many others facing a similar situation in the future :pray:

3 Likes

Hello Shawn, did you get this fulling working?

I have a developer helping me, but they are having problems with the token.

1 Like

Hey Shawn just reaching out again to see if you could share your solution? I have someone helping me out, as this is above my head, but they are facing issues.

It seems like you’ve got to the bottom of it so any help or sharing your app would be greatly appreciated!

Hi @Nate,
Yes, the connection is working fairly well. Sometimes after a few days, I’ll need to reauthorize but it is much better than having to do it every hour.

When I have time, I’m going do a little article on this. I am also considering just publishing the app. Send me a DM if you are interested and I can keep you posted. I’ve also just become a partner at Jobber and work with their Graphql API regularly. Feel free to reach out if that is what you’re looking for.

In the meantime if you (or your developer) want help with your work it is best to open a question and show specifics. You can DM me with the link and I can have a look.