locked
c++ rest sdk :casablanca RRS feed

  • Question

  • hi ,

    i am working with c++ rest sdk and wrote the following code:

    pplx::task<void> RequestJSONValueAsync()
    {
        
    	
    http_client client(L"http://www.mapquestapi.com/traffic/v2/incidents?key=Fmjtd%7Cluub2duy20%2Cb0%3Do5-9u2su4&callback=handleIncidentsResponse&boundingBox=43.050974,-106.601157,42.648250,-106.051840&filters=construction,incidents&inFormat=kvp&outFormat=json");
        
        return client.request(methods::GET).then([](http_response response) -> pplx::task<json::value>
        {
    	
            if(response.status_code() == status_codes::OK)
            {
             
    			return response.extract_json();
            }
     
            return pplx::task_from_result(json::value());
        })
            .then([](pplx::task<json::value> previousTask)
        {
            try
            {
                 json::value v = previousTask.get(); 
    			wcout<<v;
    		            
            }
            catch (const http_exception& e)
            {
             
                wostringstream ss;
                ss << e.what() << endl;
                std::wcout << ss.str();
            }
        });
    		
    }	
    	 
      
    
    
    int wmain()
    {
       
    	
        std::wcout << L"Calling RequestJSONValueAsync..." << endl;
        RequestJSONValueAsync().wait();    
    
       _getch();
    
    
    }

    in the follwing code the data return by http request is of the type json::value. But it is giving some error.

    and if i am taking it as type wstring than I am able to receive the data.

    can you suggest me a way how to receive the data in json::value format.

    Thanks

    Monday, July 15, 2013 9:57 AM

Answers

  • Hi,

    You have asked your question in the Training and Certification forum, please aks your question in the MSDN forum related to C++


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    MCSE:Server Infrastructure, MCSE:Desktop Infrastructure, MCSA Server 2012, Citrix CCIA & CCEE, Cisco CCNA, VMware VCP 3/4/5 Twitter: @dnyvandam http://www.dannyvandam.net


    Monday, July 15, 2013 12:09 PM
    Answerer