requests
HTTP client package available in Python to send HTTP requests, but you can use any PyPi package you’d like on Pipedream.
requests
usage notespip install
, just import requests
at the top of your step’s code and it’s available for your code to use.
To use requests
on Pipedream, you’ll just need to import the requests
PyPi package:
r
contains a lot of information about the response: its content, headers, and more. Typically, you just care about the content, which you can access in the text
property of the response:
r.encoding
, which is determined based on the HTTP headers.
If you’re dealing with JSON data, you can call r.json()
to decode the content as JSON:
r.json()
raises an exception.
GET
requestPOST
requestPOST
request, pass a dictionary with the data you’d like to send to the data
argument. Requests automatically form-encodes the data when the request is made.
Content-Type
header, meaning it will NOT be set to application/json
.If you want the header set to application/json
and don’t want to encode the dict
yourself, you can pass it using the json
parameter and it will be encoded automatically:GET
request/comments
resource, retrieving data for a specific post by query string parameter: /comments?postId=1
.
params
keyword argument, like above. When you do, requests
automatically URL-encodes the parameters for you, which you’d otherwise have to do manually.
headers
parameter:
/tmp
directory:
/tmp
directory/tmp
directory. This can be especially helpful for downloading large files: it streams the file to disk, minimizing the memory the workflow uses when downloading the file.
/tmp
directorymultipart/form-data
request with a file as a form part. You can store and read any files from the /tmp
directory.
This can be especially helpful for uploading large files: it streams the file from disk, minimizing the memory the workflow uses when uploading the file.
pd.inputs[appName]["$auth"]
: