Hey guys,
Im trying to connect to paypal from Poewr BI using the instructions of your article. Unfortunatally it is not working. May you help me?
I get an DataSource.Error: ... (400) ... : Bad Request
In Power BI there is a little button where I can jump directly to the error. It seems that the first part of the script is ok and that I am able to connect to paypal and get the token. The button takes me to 'data' so I think there is a problem with the url somewhere here in the code:
path = "v1/reporting/transactions",
startDate = "2021-11-01T00:00:00-0700",
endDate = "2022-01-01T00:00:00-0700",
fields = "all",
data = Json.Document(Web.Contents(api_url,
[
RelativePath = path,
Query = [end_date=endDate, start_Date=startDate, fields=fields],
Headers = [#"Authorization"="Bearer "&token,#"Content-Type"="application/json"]
]
)
),
I think that I used exactly your syntax. Can you explain to me what I am doing wrong?
Thanks,
Falk
Me again ...
It seems, that PowerQuery replaces the ":" in StartDate and EndDate into "%3A":
"https://api.paypal.com/v1/reporting/transactions?end_date=2022-01-01T00%3A00%3A00-0700&start_Date=2021-11-01T00%3A00%3A00-0700&fields=all"
Is maybe this the problem? If yes ... how can I fix it?
Hello,
The %3A is the url encoding for colon (:). See the link for more info.
https://www.w3schools.com/tags/ref_urlencode.ASP
Br,
Anders
Hi Anders,
thanks for your answer. As you can see ... I'm a noob in these things.
So it seems that this isn't the problem.
But then what?
Regards,
Falk
Hi Falk,
Are you trying to access the Sandbox or live data?
If you are trying the Sandbox, I believe it only contains data that you put there by creating dummy transactions
If you want to query your transactions you won't be able to do it in the Sandbox as it's not a mirror of your live account. In this case, just use the live account, as long as you are only querying data you can't do any harm.
What url are you using to access the API? The URL in your example code above (api.paypal.com) is out of date. Seems Paypal changed it without notifying me/anyone? I'll update my blog post.
Please check you are using the correct one
Regards
Phil