Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Update the content type for post calls #74

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sunank200
Copy link

Currently, the POST request does not work properly in _do_api_call as the Content-Type HTTP header should be set for PUT and POST requests.

Here by default the content type is not set for POST which results in the 415 error like the following:

requests.exceptions.HTTPError: 415 Client Error: Unsupported Media Type for url: https://api.fivetran.com/v1/groups/

This is done as part of PATCH calls as https://github.com/fivetran/airflow-provider-fivetran/blob/main/fivetran_provider/hooks/fivetran.py#L117
A similar change is required for POST calls

References:
According to the RFC 7231 section 3.1.5.5:

A sender that generates a message containing a payload body SHOULD generate a Content-Type header field in that message unless the intended media type of the enclosed representation is unknown to the sender. If a Content-Type header field is not present, the recipient MAY either assume a media type of "application/octet-stream" ([RFC2046], Section 4.5.1) or examine the data to determine its type.

It means that the Content-Type HTTP header should be set for PUT and POST requests.

 headers.update({"Content-Type": "application/json;version=2"})

closes: #73

@sunank200 sunank200 changed the title Add the content type for post calls Update the content type for post calls Apr 7, 2023
@utkarsharma2
Copy link

@sunank200 how did we verify this is working post the changes?

@thinhnd2104
Copy link

This is importance when customizing the hook and operator so we need to merge it ASAP. Thanks!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

POST call in hook should set the content-type to application/json;version=2
3 participants