Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Create a Post request with application/x-www-form-urlencoded

Hello, i need to get data from Pôle Emploi API, i succesfuly done it with GET.
But i need to provide a token to make the GET. So i genereate the token with a POST in POSTMAN and it work well.

Know i want to make this POST request in powerbi because the token expire si i need to get it each time i want to refresh data.

I found lot of solution with Json Content type but not with x-www-form-urlencoded.

I've this so far : 

 

 

 

let
    url = "https://entreprise.pole-emploi.fr/connexion/oauth2/access_token?realm=/partenaire",
    headers = [#"Content-Type" = "application/x-www-form-urlencoded", #"Accept" = "*/*"],
    postData = "{
        grant_type:client_credentials, 
        client_id:myid,
        client_secret:mykey, 
        scope:application_myid api_romev1 nomenclatureRome
        }",
    response = Html.Table(Web.Contents(url,
        [
            Headers = headers,
            Content = Text.ToBinary(postData)
        ]), {})
in
    response

 

 

But it retun an empty HTML table.

 

Anyone know where i miss something ?

Thanks.

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

Remove the "{}" in Json.Document function. This should work.

let
    url = "https://entreprise.pole-emploi.fr/connexion/oauth2/access_token?realm=/partenaire",
    headers = [#"Content-Type" = "application/x-www-form-urlencoded", #"Accept" = "*/*"],
    postData = [
        grant_type = "client_credentials", 
        client_id = "PAR_xxxxx_xxxxxxxx",
        client_secret = "xxxxxxxxxxx", 
        scope = "application_PAR_xxxxx_xxxxxxxx api_romev1 nomenclatureRome"
        ],
    response = Json.Document(Web.Contents(url,
        [
            Headers = headers,
            Content = Text.ToBinary(Uri.BuildQueryString(postData))
        ]))
in
    response

 

Regards,

Jing

View solution in original post

8 REPLIES 8
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

Use Json.Document to replace Html.Table in your code. And wrap up text string with "" in postData body. 

 

let
    url = "https://entreprise.pole-emploi.fr/connexion/oauth2/access_token?realm=/partenaire",
    headers = [#"Content-Type" = "application/x-www-form-urlencoded", #"Accept" = "*/*"],
    postData = "{
        ""grant_type"":""client_credentials"", 
        ""client_id"":myid,
        ""client_secret"":mykey, 
        ""scope"":""application_myid api_romev1 nomenclatureRome""
        }",
    response = Json.Document(Web.Contents(url,
        [
            Headers = headers,
            Content = Text.ToBinary(postData)
        ]), {})
in
    response

 

Or

let
    url = "https://entreprise.pole-emploi.fr/connexion/oauth2/access_token?realm=/partenaire",
    headers = [#"Content-Type" = "application/x-www-form-urlencoded", #"Accept" = "*/*"],
    postData = [
        grant_type:"client_credentials", 
        client_id:myid,
        client_secret:mykey, 
        scope:"application_myid api_romev1 nomenclatureRome"
        ],
    response = Json.Document(Web.Contents(url,
        [
            Headers = headers,
            Content = Text.ToBinary(Uri.BuildQueryString(postData))
        ]), {})
in
    response

 

Reference:

API POST with Bearer Token - Microsoft Power BI Community

excel - Power Query, make http POST request with form data - Stack Overflow

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Anonymous
Not applicable

Hello Jing,

 

the first one return an error : 

 

 

Expression.Error : Désolé... Nous n'avons pas pu convertir une valeur de type List en type Number.
Détails :
Value=[List]
Type=[Type]

 

 

"Cant convert List type to Number"

 

If i try the second solution i have another error saying "grant_type" isn't a valid identifier.

 

I have copy and paste theses two solution, just replacing myid and mykey with my id and my key with quote when needed.

Hi @Anonymous 

 

Sorry I had a mistake in the second code. "postData" should be a record. Try this one

let
    url = "https://entreprise.pole-emploi.fr/connexion/oauth2/access_token?realm=/partenaire",
    headers = [#"Content-Type" = "application/x-www-form-urlencoded", #"Accept" = "*/*"],
    postData = [
        grant_type = "client_credentials", 
        client_id = myid,
        client_secret = mykey, 
        scope = "application_myid api_romev1 nomenclatureRome"
        ],
    response = Json.Document(Web.Contents(url,
        [
            Headers = headers,
            Content = Text.ToBinary(Uri.BuildQueryString(postData))
        ]), {})
in
    response

 

Best regards,

Jing

Anonymous
Not applicable

I still have the same error

 

here is what i have in my request :

 

 

let
    url = "https://entreprise.pole-emploi.fr/connexion/oauth2/access_token?realm=/partenaire",
    headers = [#"Content-Type" = "application/x-www-form-urlencoded", #"Accept" = "*/*"],
    postData = [
        grant_type = "client_credentials", 
        client_id = "PAR_xxxxx_xxxxxxxx",
        client_secret = "xxxxxxxxxxx", 
        scope = "application_PAR_xxxxx_xxxxxxxx api_romev1 nomenclatureRome"
        ],
    response = Json.Document(Web.Contents(url,
        [
            Headers = headers,
            Content = Text.ToBinary(Uri.BuildQueryString(postData))
        ]), {})
in
    response

 

 

And as a result i have the same error as before "can't convert List to Number".

 

These informations still work in postman, i get my token with the same parameters.

Hi @Anonymous 

 

Can you check steps in Applied Steps pane to see which step this error starts to occur on? Maybe you can post a screenshot of the error. Or share a screenshot of the request settings in postman (remove sensitive info).

 

Jing

Anonymous
Not applicable

Here is what i send :

 

Tom_GT_1-1637144829906.png

 

 

And the next step with error :

Tom_GT_2-1637144921300.png

 

Now i show how i proceed with postman :

 

Tom_GT_3-1637145157436.png

Tom_GT_4-1637145322232.pngTom_GT_5-1637145437795.png

 

 

Hi @Anonymous 

 

Remove the "{}" in Json.Document function. This should work.

let
    url = "https://entreprise.pole-emploi.fr/connexion/oauth2/access_token?realm=/partenaire",
    headers = [#"Content-Type" = "application/x-www-form-urlencoded", #"Accept" = "*/*"],
    postData = [
        grant_type = "client_credentials", 
        client_id = "PAR_xxxxx_xxxxxxxx",
        client_secret = "xxxxxxxxxxx", 
        scope = "application_PAR_xxxxx_xxxxxxxx api_romev1 nomenclatureRome"
        ],
    response = Json.Document(Web.Contents(url,
        [
            Headers = headers,
            Content = Text.ToBinary(Uri.BuildQueryString(postData))
        ]))
in
    response

 

Regards,

Jing

Anonymous
Not applicable

HI @v-jingzhang,

it work !

Thanks you a lot.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.