Jump to content
milan

TSslHttpRest.RestParams.GetParameters - JSON value "true" vs true

Recommended Posts

The OverbyteIcsHttpRestTst.dproj sample has a grid titled REST Parameters where i enter Name - "verify" and Value - "true".

I need JSON {"verify":true} but method RestParams.GetParameters return {"verify":"true"}. 

Parameter aRaw make nothing.

Share this post


Link to post

Sorry, currently TRestParams does not create boolean or numeric parameters, you'll need to construct the Json manually or with SuperObject.

 

Angus

 

Share this post


Link to post

Thank you and at the same time please:

construct the Json manually, but where to assign in?

 

Milan

Share this post


Link to post

But if it does not take place function GetParams, 

will stay after THttpCli.Create  FContentPost := 'application/x-www-form-urlencoded'
because it will not be replaced: 

 

OverbyteIcsSslHttpRest.pas:

...

line 1818

     { V8.64 set Json content type if empty }
        if (Params <> '') and (FContentPost = '') then begin
           if (Params[1] = '{') or (Params[1] = '[') then
                FContentPost := 'application/json; charset=UTF-8';  { V8.61 added UTF8 }
 

excuse my English

 

Milan

Edited by milan

Share this post


Link to post

If you use RawParams you also need to set ContentPost to say what you are posting. 

 

BTW, all the REST APIs I've used so far have accepted a Json value of 'True', but I will look at improving TRestParams, not immediately though.

 

Angus

 

Share this post


Link to post

Thank you very much.

 

In the meantime I will set HttpRest.ContentTypePost : = ''; (instead 'application/x-www-form-urlencoded' set from Create) 

and code in OverbyteIcsSslHttpRest.pas:

 

line 1818

     { V8.64 set Json content type if empty }
        if (Params <> '') and (FContentPost = '') then begin
           if (Params[1] = '{') or (Params[1] = '[') then
                FContentPost := 'application/json; charset=UTF-8';  { V8.61 added UTF8 }

 

will come into effect.

 

Milan

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×