[ 
https://issues.apache.org/jira/browse/AIRFLOW-6327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17006186#comment-17006186
 ] 

ASF GitHub Bot commented on AIRFLOW-6327:
-----------------------------------------

nuclearpinguin commented on pull request #6886: [AIRFLOW-6327] http_hook: 
Accept json= parameter for payload
URL: https://github.com/apache/airflow/pull/6886
 
 
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> http_hook: Accept json= parameter for payload
> ---------------------------------------------
>
>                 Key: AIRFLOW-6327
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-6327
>             Project: Apache Airflow
>          Issue Type: Improvement
>          Components: hooks
>    Affects Versions: 1.10.6
>            Reporter: Bjorn Olsen
>            Assignee: Bjorn Olsen
>            Priority: Minor
>
> Python requests library allows a user to send json-encoded Python objects by 
> making use of the "json=" parameter to a request.
> This handles JSON encoding of the payload and setting the correct content 
> type header.
> Example:
> {code:python}
> response = requests.post('https://httpbin.org/post', json={'key':'value'})
> json_response = response.json() 
> json_response['data'] '{"key": "value"}' 
> json_response['headers']['Content-Type'] 'application/json'
> {code}
> http_hook.run() does not yet have the json= parameter which is inconvenient 
> as then we have to pass the "data=" parameter using json.dumps and specify 
> the correct headers.
> It would be better if we can just do something like the below and let the 
> Requests library ensure the request is valid:
> {code:python}
> obj = {'a':1, 'b': 'abc', 'c': [1, 2, {"d":10}]}
> response = hook.run(
>      endpoint,
>      json=obj)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to