I have difficulties converting a post request using htppie to python requests.post. This question is in general about how to do such a conversion, but I will use the specific request I was doing as an example.
So I have the following post request using httpie, which works fine:
http post https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet query='{ indexers {
id
}
}'
However, when trying to send the same request using pythons requests library, I tried the following:
import requests
url = 'https://api.thegraph.com/subgraphs/name/graphprotocol/graph-network-mainnet'
query = """'{ indexers {
id
}
}'"""
print(requests.post(url, data = query).text)
This gives a server error (I tried many versions of this, as well as sending a dictionary for the data variable, and they all give the same error). The server error was GraphQL server error (client error): expected value at line 1 column 1
.
Regardless of what the server error is (which is probably server specific), this at least means that the two requests obviously are not exactly the same.
So how would I go about converting this httpie request to using pythons requests library (or any other python library for that matter)?