Forum

Notifications
Clear all

Connecting to PayPal in Power BI

5 Posts
3 Users
0 Reactions
114 Views
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
Topic starter
 

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

 
Posted : 10/02/2022 10:46 am
(@phulc)
Posts: 2
New Member
 

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?

 
Posted : 10/02/2022 11:13 am
Anders Sehlstedt
(@sehlsan)
Posts: 970
Prominent Member
 

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

 
Posted : 10/02/2022 6:32 pm
(@phulc)
Posts: 2
New Member
 

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

 
Posted : 11/02/2022 2:42 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
Topic starter
 

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

PayPal sandbox testing guide

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

API requests (paypal.com)

Regards

Phil

 
Posted : 09/03/2022 11:02 pm
Share: