fabriciocolombo / delphi-rest-client-api

A Delphi REST client API to consume REST services written in any programming language.
Apache License 2.0
380 stars 182 forks source link

ContentTypes #57

Closed rafakwolf closed 7 years ago

rafakwolf commented 8 years ago

How can i set ContentType = 'application/x-www-form-urlencoded' ?

Thanks

RobertoSchneiders commented 8 years ago

This should work (from Post example):

RestClient.Resource('http://localhost:8080/java-rest-server/rest/person')
            .Accept(RestUtils.MediaType_Json)
            .ContentType('application/x-www-form-urlencoded')
            .Post<TPerson>(vPerson);
rafakwolf commented 8 years ago

Thanks!

rafakwolf commented 8 years ago

@RobertoSchneiders

Did not work :(

RobertoSchneiders commented 8 years ago

What exactly is happening @rafakwolf?

rafakwolf commented 8 years ago

The APIs with Bearer Token authentication, needs the application/x-www-form-urlencoded to request for tokens... so, the receiving response is ( _unsupported granttype ) with status code 400.

RobertoSchneiders commented 8 years ago

@rafakwolf I don't think this is a problem related to this library.

The error unsupported grant_type suggest that you are not passing the correct grant_type parameter to the request or you are not informing this parameter at all.

It should look like this:

grant_type=password&username=yourusername&password=yourpassword

http://stackoverflow.com/a/29261024

If this doesn't help, can you share your code with us? What API you are trying to consume?

fabriciocolombo commented 7 years ago

Closed by inactivity.