Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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 ...
  • v-jingzhang's avatar
    v-jingzhang
    4 years ago

    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