Forum Discussion

cmht's avatar
cmht
Regular Visitor
2 years ago

API query error 415 unsupported media type in Aconex (POST request)

Hello,

I have a problem that Aconex API shows me "415 unsupported media type".

 

Below my code with some comments

let
authKey ="Basic " & AconexAuthorizationPair, //100% works, I am sending it as Base64 encoded username:password
 
//Retrieve token from Aconex
GetJson =
Web.Contents(
[
Headers=[
#"Content-Type"="x-www-form-urlencoded",
#"Authorization"=authKey
],
Content= Text.ToBinary("grant_type=client_credentials")
]
),
 
FormatAsJson = Json.Document(GetJson),
 
//Extract token from Json response
AccessToken = "Bearer " & FormatAsJson[access_token]
 
in
AccessToken
 
 
What I am doing wrong?
Below an example from documentation cURL request:
--header 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8' \
--header 'Authorization: Basic <BASE_64_ENCODED_CREDENTIALS>' \
--data-urlencode 'grant_type=client_credentials'
 
And an example response in JSON format:
{
"access-token": "eyJ4NQXjUzI1NiI...KtK5elB38rcAbgFtVP9A",
"token-type": "Bearer",
"expires-in": 7200
}
 
Thank you, any help would be really appreciated.

1 Reply