Summary
The user is facing an issue when trying to invoke the Airbyte API inside a Google Apps Script. The error indicates that a required body ‘jobCreate’ is not specified, even though the user is attempting to invoke a ‘sync’ instead of creating a job.
Question
I am attempting to invoke the Airbyte API inside a google Apps Script. The API call works fabulously from the API website. when copied into the Gsheet App script code, it fails with the error ‘Error making API call: { [Exception: Request failed for https://api.airbyte.com returned code 400. Truncated server response: {“type”:“about:blank”,“parameters”:{“path”:“/jobCreate”},“status”:400,“detail”:“Required Body [jobCreate] not specified”} (use muteHttpExceptions option to examine full response)] name: ‘Exception’ }’
however, I am not attempting to create a job, I am simply attempting to invoke a sync
.
The call looks like this:
const options = {
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
authorization: 'Bearer ****API TOKEN*****'
},
body: JSON.stringify({jobType: 'sync', connectionId: '07de0931-be90-48fb-b08a-68e67080fd87'})
};
try {
const response = UrlFetchApp.fetch('<https://api.airbyte.com/v1/jobs>', options);
const jsonResponse = response.getContentText();
console.log(jsonResponse); // Log the response for debugging
// Optionally, process the response data as needed
// ...
} catch (error) {
console.error('Error making API call:', error);
}
}```
Is there a known issue with being able to do this within Google App scripts?
<br>
---
This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. [Click here](https://airbytehq.slack.com/archives/C021JANJ6TY/p1706028962074949) if you want to access the original thread.
[Join the conversation on Slack](https://slack.airbyte.com)
<sub>
["airbyte-api", "google-apps-script", "api-call", "sync", "error"]
</sub>