Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: POST method syntax

$
0
0
Hello Steve,

Saw you video on using C++ to connect to a web service on you-tube. Very helpful. Thanks..
My question is, from the code or set up on the you-tube video, how can i send a file or its content as the request to a sever rath then just strings i type out?
my issue is the syntax. Code below


int _tmain(int argc, _TCHAR* argv[])

{
//gets file data and converts it to string
string data = get_file_contents( "my file with content");

//connection to server
http_client client (U("my restful webservice"));

//sending data as request, will like to send file and its content rather than just this, converting data to string and sending it is fine too
http_response response = client.request(methods::POST, U(data)).get();...this is where i get the error with my syntax

//response from web service
if(response.status_code() == status_codes::OK)
{
    const utility::string_t body = response.extract_string().get();
    std::wcout<<body;
}


getchar();

return 0;
}

Also can i send the file content as string or have to convert it to string_t?

Thank you for a speedy response, this is the last part of my work.

Regards,

Steven

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>