I'm trying to create an API connection between Twitter and Power BI but I'm having no luck at all.
I only need to pull my own user info and not all users historical data.
I believe I require an API key, and API access token and a Bearer token which I've been able to get from my Twitter Dev account.
My problem is that I need to translate the documented cURL request link into something that Power BI can accept and I have no idea how to go about this.
Example cURL request:
curl 'https://api.twitter.com/2/tweets?ids=1204084171334832128&tweet.fields=public_metrics&expansions=attachments.media_keys&media.fields=public_metrics' --header 'Authorization: Bearer $BEARER_TOKEN'
I believe I have to insert some M language code into the "Advanced Editor" in Power Query for this to work but I haven't been able to find any such information on the internet.
Any help wuould be most appreciated!
@Anonymous I see the same error when i re-open that pbix, as I've cancelled the authkey since I've shared this. Did you go to the Source step and replace the code with yours (keep the "Basic " part)? Once that is working, you can replace the query part with what you want (q= ).
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi @mahoneypat , @PhilipTreacy
Hope you can help. I used your sample file and i am facing the issue while generating the token number. See below.
M-Query
let
// Basic auth
authKey = "Basic ****************************",
url = "https://api-e2e.danfoss.com/oauth2/token",
// bearer token
GetJson = Web.Contents(url,
[
Headers = [#"Authorization"=authKey,
#"Content-Type"="application/x-www-form-urlencoded;charset=UTF-8"],
Content = Text.ToBinary("grant_type=client_credentials")
]
)
in
GetJson
Error msg
See the working http from postman
thanks in advance for your support
Hi guys!
Thanks hugely for your help!
I'm still getting no where with this.
Hi @Anonymous
I'm trying to set up my Twitter Dev account but having some issues with Twitter. Waiting on them to sort it out before I can test this for you.
Regards
Phil
Proud to be a Super User!
Hi, thanks hugely for answering with an example but unfortunatley it doesn't work.
I get the error "Expression.Error: Access to the resource is forbidden."
In that example, was the data being pulled my own user or all Twitters user data?
Once again, your help is greatly appreciated!
I hope this is not out of date, but here this pbix contains an example of getting Twitter data. You need to use the AuthKey to go get a temporary authentication token to use with your actual data web calls. I changed the first step (authkey) to not share my key, so you should just need to update that and then change the query parameters in that step (the one with ?q=Microsoft
Please let me know if it still works.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
User | Count |
---|---|
142 | |
61 | |
59 | |
58 | |
47 |
User | Count |
---|---|
136 | |
72 | |
59 | |
56 | |
52 |