Hello!
I am trying to create a new app that I use for my business called Jobber, but I am really having a hard time as I’m pretty new at this. Jobber has provided the following information for the integration:
API Queries and Mutations
Make an Endpoint Request
Jobber's API is GraphQL based. This means all API requests are sent via POST to the following URL:
https://api.getjobber.com/api/graphql
To make a successful request you must include a header with the Authorization key, and a value consisting of the access token you received via the OAuth 2.0 flow prepended with the word 'bearer'. See the example curl request below.
curl -X POST -H "Authorization: Bearer <ACCESS_TOKEN>" "https://api.getjobber.com/api/graphql"
Assuming the access token is valid, the API will process the request according to its API specifications. If the access token is invalid, the API will return a 401 "invalid_request" error.
API Queries
In order to request data from the API you will need to include a GraphQL query in the payload of your API request.
Query Example:
{
"query": "query SampleQuery {
clients {
nodes {
id
firstName
lastName
billingAddress {
city
}
}
totalCount
}
}",
"operationName": "SampleQuery"
}
API Mutations
Any time you would like your app to modify any data in Jobber, a GraphQL mutation will be required.
Mutation Example:
{
"query": "mutation SampleMutation {
clientCreate(
input: {firstName: "Jane", lastName: "Doe", companyName: "Jane's Automotive",
emails: [{description: MAIN, primary: true, address: "jane.doe@example.com"}]}
) {
client {
id
firstName
lastName
}
userErrors {
message
path
}
}
}",
"operationName": "SampleMutation"
}
For more on how to use GraphQL see the Official guides.
Steps I’ve taken:
- My Apps > Create a New Connection > OAuth 2 (authorization code)
- This is how I modified the code
{
// Step 1: OAuth2 authorization request for Jobber
"authorize": {
"url": "https://api.getjobber.com/oauth/authorize",
"qs": {
"scope": "{{join(oauth.scope, ',')}}",
"client_id": "MYJOBBERCLIENTID",
"redirect_uri": "{{oauth.redirectUri}}",
"response_type": "code"
},
"response": {
"temp": {
"code": "{{query.code}}"
}
}
},
// Step 2: OAuth2 token request for Jobber
"token": {
"url": "https://api.getjobber.com/oauth/token",
"method": "POST",
"body": {
"code": "{{temp.code}}",
"client_id": "MYJOBBERCLIENTID",
"grant_type": "authorization_code",
"redirect_uri": "{{oauth.redirectUri}}",
"client_secret": "MYJOBBERSECRETID"
},
"type": "urlencoded",
"response": {
"data": {
"accessToken": "{{body.access_token}}"
}
},
"log": {
"sanitize": [
"request.body.code",
"request.body.client_secret",
"response.body.access_token"
]
}
},
// Use the obtained access token to make GraphQL queries and mutations
"graphql": {
"url": "https://api.getjobber.com/api/graphql",
"method": "POST",
"headers": {
"Authorization": "Bearer {{body.access_token}}"
},
"body": {
"query": "query SampleQuery { clients { nodes { id firstName lastName billingAddress { city } } totalCount } }",
"operationName": "SampleQuery"
},
"response": {
"data": {
// Modify this section based on the expected data structure from the GraphQL query
"clients": "{{body.clients}}"
}
},
"log": {
"sanitize": ["request.headers.authorization"]
}
}
}
What am I missing? How do I verify if it is working correctly or if it isn’t? Thank you in advance for your help!! I really need it.