[
https://issues.apache.org/jira/browse/AIRFLOW-6327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17022107#comment-17022107
]
ASF subversion and git services commented on AIRFLOW-6327:
----------------------------------------------------------
Commit 04e4521c8d9b6f272a8ce472a01b4c07efac218a in airflow's branch
refs/heads/v1-10-test from Bjorn Olsen
[ https://gitbox.apache.org/repos/asf?p=airflow.git;h=04e4521 ]
[AIRFLOW-6327] http_hook: Accept json= parameter for payload (#6886)
* [AIRFLOW-6327] http_hook: Accept json= parameter for payload
* [AIRFLOW-6327] CODE REVIEW
* [AIRFLOW-6327] CODE REVIEW 2
* [AIRFLOW-6327] CODE REVIEW 3
Co-Authored-By: dstandish <[email protected]>
Co-authored-by: dstandish <[email protected]>
(cherry picked from commit fd78c65cabae2241a4c1d3a792e00620049cbf3e)
> 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
> Fix For: 1.10.8
>
>
> 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)