2.1.21.12 okutil_http_post


Description

Make a request to a specified server using POST.

Syntax

int okutil_http_post( LPCSTR lpcszURL, LPCSTR lpcszRequestData, string * pstrResult, int nConnectTimeout = 0, int nResponseTimeout = 30 )

Parameters

lpcszURL
[input] the web service URL
lpcszRequestData
[input] request data
pstrResult
[output] result from the call
nConnectTimeout
[input] the number of seconds an HTTP request has to establish a connection before it times out.
nResponseTimeout
[input] the number of seconds to wait for a response.

Return

0 if succcess, otherwise an negative error code

Examples

EX1

void molecule()
{
    string strURL = "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/property/MolecularFormula,MolecularWeight/JSON";
    string strRequest = "cid=1,2,3,4,5";
    string result;
    int err = okutil_http_post(strURL, strRequest, &result);
    if(0==err) {
        Tree tr;
        JSON.FromString(tr, result);
        out_tree(tr);
    }
}

Remark

See Also

Header to Included

origin.h

Reference