On Sun, 03 Dec 2017 16:04:01 GMT, kerdemdemir wrote:

I need to create a request similar to

 curl -X POST -u "ff20f250a7b3a414781d1abe11cd8cee:fb453577d11294359058a9ae13c94713" \
"https://api.hitbtc.com/api/2/order/" \
-d 'symbol=ETHBTC&side=sell&quantity=0.063&price=0.046016'

The example above is taken from: https://api.hitbtc.com/#create-new-order

I am trying to achieve that with:

string[string] params;
params["symbol"] = "ETHBTC";
params["side"] = "sell";
params["quantity"] = to!string(quantity);
params["price"] = to!string(price);

string url = "https://api.hitbtc.com/api/2/order" ;
try
{
	requestHTTP(url.dup,
		(scope req) {
			req.addBasicAuth(apikey, apisecret);
			req.method = HTTPMethod.POST;
			req.writeFormBody( params );
		},
		(scope res) {
			writeln(res.bodyReader.readAllUTF8());
		}
	);
}

Basic auth part is working I tested it with some other function . But I am getting a error about parameter "symbol" not found.

Is using writeFormBody correct to achieve the same result of -d option of curl? If not what should I use instead?

The code looks fine as far as I can see. In case of any order dependency of the parameters, instead of a string[string], a Tuple!(string, string)[] array can be passed to writeFormBody with key-value pairs.

If that doesn't help, dumping the raw request and comparing it with curl would be my next attempt. The headers can be seen by running with dub -- --vvvv, whereas the body, since HTTPS is used here, can probably displayed in the most straight forward way by calling vibe.inet.webform.formEncode with the same params value and an appender!string as the target.