RejectedSoftware Forums

Sign up

Posting form data from a vibe.d client to a unknown server

Hi,
I am trying to use the
auto client = RestInterfaceClient!Zoho("https://creator.zoho.com/api/zoho_xxx/json/testapi/form/Orders/record/add");

where the interface is as follows:
module zoho;

struct orderToSubmit {

string authtoken;
string scope_;
string Depot;
string RTU;
string Order_Date_Time;
string Device_Id;
string Device_Serial_Number;
int Days_Left;
string Supply_Code;

}

interface Zoho {

 ubyte[][] postOrder(orderToSubmit theOrder);

}

the call looks like auto theResponse = client.postOrder(theOrder);

The server requires the data(theOrder) to be passed as form data. The data is actually passed as JSON.

How can I get the data to be encoded as form data using this method?

Any suggestions are definitely appreciated.

Thanks

John

Re: Posting form data from a vibe.d client to a unknown server

On Tue, 26 Apr 2016 16:00:06 GMT, John More wrote:

Hi,
I am trying to use the
auto client = RestInterfaceClient!Zoho("https://creator.zoho.com/api/zoho_xxx/json/testapi/form/Orders/record/add");

where the interface is as follows:
module zoho;

struct orderToSubmit {

string authtoken;
string scope_;
string Depot;
string RTU;
string Order_Date_Time;
string Device_Id;
string Device_Serial_Number;
int Days_Left;
string Supply_Code;

}

interface Zoho {

 ubyte[][] postOrder(orderToSubmit theOrder);

}

the call looks like auto theResponse = client.postOrder(theOrder);

The server requires the data(theOrder) to be passed as form data. The data is actually passed as JSON.

How can I get the data to be encoded as form data using this method?

Any suggestions are definitely appreciated.

Thanks

John

I got it to work by foregoing the RestInterfaceClient and using

  HTTPClientResponse res = requestHTTP(completeURL,
                          (scope req)
                         { req.method = HTTPMethod.POST;
                           req.writeFormBody(form);}
                         );

I would still like to see if there is a way to make the Interface work.

John

Re: Posting form data from a vibe.d client to a unknown server

The REST interface generator is still in the process of being generalized more (it started out as a means to define simple fixed REST protocols, and now evolves more and more into something that can map to arbitrary REST protocols instead). Once some form custom serialization gets added (probably in the form of a user defined attribute), using form data will become possible.

Re: Posting form data from a vibe.d client to a unknown server

On Mon, 02 May 2016 12:39:22 GMT, Sönke Ludwig wrote:

The REST interface generator is still in the process of being generalized more (it started out as a means to define simple fixed REST protocols, and now evolves more and more into something that can map to arbitrary REST protocols instead). Once some form custom serialization gets added (probably in the form of a user defined attribute), using form data will become possible.

Your efforts are appreciated.
Thanks