[ https://issues.apache.org/jira/browse/AIRFLOW-6327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17006187#comment-17006187 ]
ASF subversion and git services commented on AIRFLOW-6327: ---------------------------------------------------------- Commit fd78c65cabae2241a4c1d3a792e00620049cbf3e in airflow's branch refs/heads/master from Bjorn Olsen [ https://gitbox.apache.org/repos/asf?p=airflow.git;h=fd78c65 ] [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 <dstand...@users.noreply.github.com> Co-authored-by: dstandish <dstand...@users.noreply.github.com> > 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)