Reputation: 838
I'm trying to send a GET request to an API endpoint with some parameters, but the parameters are ignored by the endpoint.
I have tried to define p in many ways, without succes. I get the result back as if no parameters were added to the request.
How is this done? I expect, that it has to go into the URL somehow.
API docs says that a query Parameter "fields" can be added, and that it must contain a list of fields to be returned:
fields
string Nullable
Default: "Guid,ContactName,Date,Description"
A comma separated list of fields to include in the response. Possible values are: Number, Guid, ExternalReference, ContactName, ContactGuid, Date, PaymentDate, Description, Currency, Status, MailOutStatus, TotalExclVatInDkk, TotalInclVatInDkk, TotalExclVat, TotalInclVat, CreatedAt, UpdatedAt and DeletedAt. If null, defaults to Guid,ContactName,Date,Description. Notice that it's not case sensitive, the property name will be returned the way you request it.
This is my code
import requests
url = 'https://api.dinero.dk/v1/257403/invoices'
headers = { 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + token }
p = {'fields' :"Number, Guid, ContactName, Date, Status"}
response = requests.get(url, headers=headers, params=p)
print (response.text)
Upvotes: 2
Views: 1338
Reputation: 10090
I think this is happening because you're including spaces in your p['fields']
value. try using:
p = {'fields': "Number,Guid,ContactName,Date,Status"}
Upvotes: 1