Thread: Mimicking "Export Data to Excel" Post Request does not download Excel file?

  1. #1
    Registered User
    Join Date
    Jun 2018
    Posts
    26

    Mimicking "Export Data to Excel" Post Request does not download Excel file?

    Hi,

    I want to know if I am going in the right direction with this.

    BACKGROUND:

    I made a mistake in the last thread I started that was identical to this.

    I have a website that I am building a program for using libcurl.

    The program is supposed to automate the tasking of pulling the appropriate data on the website and then exporting it to Excel.

    Unlike before in the previous thread I am now able to see the data in the console.

    I just need to figure out the last step, which is exporting the data to Excel.

    In the last thread that I started I thought that the event validation token (see below) changed every time data was pulled- it does not. I accidentally copied down the wrong event validation string, which was causing me not to see the data in the console.

    PROBLEM:

    There is an "Export to Excel" button that you would click when manually doing the task I am trying to automate- I have mimicked the POST request for it, but doing that does not download any Excel file.

    I incorporated the libcurl write function and write data commands into my code to try and write the data to the excel file, played around with their placement within the code, but cannot seem to get anything other than a blank Excel file.


    CODE SEGMENT:


    Code:
    
     curl_mime_data(partthreehundredeightytwo, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partthreehundredeightythree, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partthreehundredeightyfour, "__EVENTTARGET");
     curl_mime_data(partthreehundredeightyfour, "" , CURL_ZERO_TERMINATED);
    
    
    
    
     curl_mime_data(partthreehundredeightyfive, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partthreehundredeightysix, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partthreehundredeightyseven, "__EVENTARGUMENT");
     curl_mime_data(partthreehundredeightyseven, "" , CURL_ZERO_TERMINATED);
    
    
     curl_mime_data(partthreehundredeightyeight, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partthreehundredeightynine, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partthreehundredninety, "__LASTFOCUS");
     curl_mime_data(partthreehundredninety, "" , CURL_ZERO_TERMINATED);
    
    
     curl_mime_data(partthreehundredninetyone, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partthreehundredninetytwo, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partthreehundredninetythree, "__VIEWSTATE");
     curl_mime_data(partthreehundredninetythree, "" , CURL_ZERO_TERMINATED);
    
    
     curl_mime_data(partthreehundredninetyfour, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partthreehundredninetyfive, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partthreehundredninetysix, "__EVENTVALIDATION");
     curl_mime_data(partthreehundredninetysix, "/wEWMgL+raDpAgLbwrnWDgKks+v+BwLjovzDDQKrzdy6DgLT6eXADAKlu627BgLylcmLAQKYutH+DQKyy7U3AtjkrcIMAvjMxcICAvHJ6N8DAoWO2poCAoqQwaQNAt3XgvUMAoycqbUOAqeFx8oIAtbJ7YoKAvGyi6AEAtCKj7QIAuvzrMkCAvjApIoHApOqwp8BAsLu6N8CAt3XhvUMAtTdzskPAu/G7N4JAoqwivQDAqWZqIkOAsCCxp4IAqvYhuAPAsbBpPUJAoOi8YkBAp6Lj58LArn0rLQFAtTdyskPAoim9K8MAoG63ucHAuKjvssIAuzO7bULAqfx68oFApWN5o4BAtXEvLADAu/v08sFAu/v18sFAu/v28sFAu/v38sFAujpnqAFAvGNtZUPaAaLE+bDvs3djyb6GRujHvK1NzA=" , CURL_ZERO_TERMINATED);
     
      curl_mime_data(partthreehundredninetyone, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partthreehundredninetytwo, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partthreehundredninetythree, "ctl00$Pager");
     curl_mime_data(partthreehundredninetythree, "" , CURL_ZERO_TERMINATED);
    
    
     curl_mime_data(partthreehundredninetyfour, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partthreehundredninetyfive, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partthreehundredninetysix, "ctl02$G2$4_3_100003423_0_0_0_1$showDropDownList");
     curl_mime_data(partthreehundredninetysix, "PAGE" , CURL_ZERO_TERMINATED);
     
      curl_mime_data(partthreehundredninetyseven, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partthreehundredninetyeight, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partthreehundredninetynine, "ctl02$G2$4_3_100003423_0_0_0_1$outputFilterDropDownlist");
     curl_mime_data(partthreehundredninetynine, "ALL" , CURL_ZERO_TERMINATED);
    	 
     curl_mime_data(partfourhundred, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredone, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredtwo, "ctl02$G2$4_3_100003423_0_0_0_1$exportTypeDropDownList");
     curl_mime_data(partfourhundredtwo, "EXCEL" , CURL_ZERO_TERMINATED);
     
     
     	 
     curl_mime_data(partfourhundred, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredone, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredtwo, "ctl02$G2$4_3_100003423_0_0_0_1$hiddenexportButton");
     curl_mime_data(partfourhundredtwo, "Export Hidden" , CURL_ZERO_TERMINATED);
     
     
     curl_mime_data(partfourhundredthree, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredfour, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredfive, "ctl02xG2x4x3x100003423x0x0x0x1xruntimeWebGrid");
     curl_mime_data(partfourhundredfive, "" , CURL_ZERO_TERMINATED);
     
     
     curl_mime_data(partfourhundredsix, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredseven, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredeight, "ctl02$G2$4_3_100003423_0_0_0_1$clientIdListHidden");
     curl_mime_data(partfourhundredeight, "ctl02_G2_4_3_100003423_0_0_0_1_selectedRowsClientIdHidden,ctl02_G2_4_3_100003423_0_0_0_1_selectedRowsIndexHidden,ctl02_G2_4_3_100003423_0_0_0_1_customRowColorsHidden,ctl02_G2_4_3_100003423_0_0_0_1_rowSelectionModeHidden,ctl02_G2_4_3_100003423_0_0_0_1_totalSelectedRowsCountHidden,ctl02_G2_4_3_100003423_0_0_0_1_alternateRowColorHidden,ctl02_G2_4_3_100003423_0_0_0_1_selectedRowsLabel," , CURL_ZERO_TERMINATED);
     
    
    
    curl_mime_data(partfourhundrednine, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredten, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredeleven, "ctl02$G2$4_3_100003423_0_0_0_1$rowSelectionModeHidden");
     curl_mime_data(partfourhundredeleven, "1" , CURL_ZERO_TERMINATED);
     
    curl_mime_data(partfourhundredtwelve, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredthirteen, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredfourteen, "ctl02$G2$4_3_100003423_0_0_0_1$selectedRowsIndexHidden");
     curl_mime_data(partfourhundredfourteen, "" , CURL_ZERO_TERMINATED);
     
     
    curl_mime_data(partfourhundredfifteen, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredsixteen, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredseventeen, "ctl02$G2$4_3_100003423_0_0_0_1$selectedRowsClientIdHidden");
     curl_mime_data(partfourhundredseventeen, "" , CURL_ZERO_TERMINATED); 
     
     
    curl_mime_data(partfourhundredeighteen, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundrednineteen, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredtwenty, "ctl02$G2$4_3_100003423_0_0_0_1$customRowColorsHidden");
     curl_mime_data(partfourhundredtwenty, "WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke" , CURL_ZERO_TERMINATED);
    
    
    
    
    curl_mime_data(partfourhundredtwentyone, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredtwentytwo, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredtwentythree, "ctl02$G2$4_3_100003423_0_0_0_1$alternateRowColorHidden");
     curl_mime_data(partfourhundredtwentythree, "#FAFAFA" , CURL_ZERO_TERMINATED); 
     
    
    
    curl_mime_data(partfourhundredtwentyfour, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredtwentyfive, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredtwentysix, "ctl02$G2$4_3_100003423_0_0_0_1$totalSelectedRowsCountHidden");
     curl_mime_data(partfourhundredtwentysix, "0" , CURL_ZERO_TERMINATED); 
    
    
    
    
    curl_mime_data(partfourhundredtwentyseven, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredtwentyeight, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredtwentynine, "ctl02$G3$4_RoutingFunction_Routing_133_0$Editor$Selected_0");
     curl_mime_data(partfourhundredtwentynine, "false" , CURL_ZERO_TERMINATED); 
     
     
    curl_mime_data(partfourhundredthirty, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredthirtyone, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredthirtytwo, "ctl02$G3$4_RoutingFunction_Routing_133_0$Editor$Selected_1");
     curl_mime_data(partfourhundredthirtytwo, "false" , CURL_ZERO_TERMINATED); 
     
     curl_mime_data(partfourhundredthirtythree, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredthirtyfour, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredthirtyfive, "ctl02$G3$4_RoutingFunction_Routing_133_0$Editor$Selected_2");
     curl_mime_data(partfourhundredthirtyfive, "false" , CURL_ZERO_TERMINATED);
     
      curl_mime_data(partfourhundredthirtysix, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredthirtyseven, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredthirtyeight, "ctl02$G3$4_RoutingFunction_Routing_133_0$Editor$Selected_3");
     curl_mime_data(partfourhundredthirtyeight, "false" , CURL_ZERO_TERMINATED);
     
       curl_mime_data(partfourhundredthirtynine, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredforty, "Content-Disposition: form-data;" , CURL_ZERO_TERMINATED);
     curl_mime_name(partfourhundredfortyone, "_IG_CSS_LINKS_");
     curl_mime_data(partfourhundredfortyone, "businesscontrols/styles/ig_uwg_styles/mm/ig_grid_opt.css|businesscontrols/styles/ig_uwg_styles/mm/ig_shared.css" , CURL_ZERO_TERMINATED);
     curl_mime_data(partfourhundredfortytwo, "------WebKitFormBoundarySx0D888gByBvORTu" , CURL_ZERO_TERMINATED);
    
    
    
    
    	 	 	 
    	 /* Set the form info */
     curl_easy_setopt(myHandle, CURLOPT_COOKIEFILE, "cookies.txt");
     curl_easy_setopt(myHandle, CURLOPT_MIMEPOST, multipartfive);
     curl_easy_perform(myHandle); /* post away! */ 
     
     /* free the post data again */
    curl_mime_free(multipartfive);
    	 
    
    
    
    
    // DOWNLOAD FILE 
    
    
    
    
         FILE *fp;
        CURLcode res;
       
        char outfilename[FILENAME_MAX] = "C:\data.xls";
       
        if (myHandle) {
            fp = fopen(outfilename,"wb");
            
            
            curl_easy_setopt(myHandle, CURLOPT_WRITEFUNCTION, write_data);
            curl_easy_setopt(myHandle, CURLOPT_WRITEDATA, fp);
            res = curl_easy_perform(myHandle);
            /* always cleanup */
            curl_easy_cleanup(myHandle);
            fclose(fp);
        }
    	   return 0;
    }

    POST REQUEST PAYLOAD:


    ------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="__EVENTTARGET"------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="__EVENTARGUMENT"------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="__LASTFOCUS"------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="__VIEWSTATE"------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="__EVENTVALIDATION"/wEWMgL+raDpAgLbwrnWDgKks+v+BwLjovzDDQKrzdy6DgLT6eX ADAKlu627BgLylcmLAQKYutH+DQKyy7U3AtjkrcIMAvjMxcICA vHJ6N8DAoWO2poCAoqQwaQNAt3XgvUMAoycqbUOAqeFx8oIAtb J7YoKAvGyi6AEAtCKj7QIAuvzrMkCAvjApIoHApOqwp8BAsLu6 N8CAt3XhvUMAtTdzskPAu/G7N4JAoqwivQDAqWZqIkOAsCCxp4IAqvYhuAPAsbBpPUJAoOi8 YkBAp6Lj58LArn0rLQFAtTdyskPAoim9K8MAoG63ucHAuKjvss IAuzO7bULAqfx68oFApWN5o4BAtXEvLADAu/v08sFAu/v18sFAu/v28sFAu/v38sFAujpnqAFAvGNtZUPaAaLE+bDvs3djyb6GRujHvK1NzA=------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl00$Pager"------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$showDropDownL ist"PAGE------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$outputFilterD ropDownlist"ALL------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$exportTypeDro pDownList"EXCEL------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$hiddenexportB utton"Export Hidden------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02xG2x4x3x100003423x0x0x0x1xruntimeWebGri d"------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$clientIdListH idden"ctl02_G2_4_3_100003423_0_0_0_1_selectedRowsC lientIdHidden,ctl02_G2_4_3_100003423_0_0_0_1_selec tedRowsIndexHidden,ctl02_G2_4_3_100003423_0_0_0_1_ customRowColorsHidden,ctl02_G2_4_3_100003423_0_0_0 _1_rowSelectionModeHidden,ctl02_G2_4_3_100003423_0 _0_0_1_totalSelectedRowsCountHidden,ctl02_G2_4_3_1 00003423_0_0_0_1_alternateRowColorHidden,ctl02_G2_ 4_3_100003423_0_0_0_1_selectedRowsLabel,------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$rowSelectionM odeHidden"1------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$selectedRowsI ndexHidden"------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$selectedRowsC lientIdHidden"------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$customRowColo rsHidden"WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmo ke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,Whi teSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmok e,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,Whit eSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke,WhiteSmoke ,WhiteSmoke,WhiteSmoke,WhiteSmoke------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$alternateRowC olorHidden"#FAFAFA------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G2$4_3_100003423_0_0_0_1$totalSelected RowsCountHidden"0------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G3$4_RoutingFunction_Routing_133_0$Edi tor$Selected_0"false------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G3$4_RoutingFunction_Routing_133_0$Edi tor$Selected_1"false------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G3$4_RoutingFunction_Routing_133_0$Edi tor$Selected_2"false------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="ctl02$G3$4_RoutingFunction_Routing_133_0$Edi tor$Selected_3"false------WebKitFormBoundary3cR2BphPfiDBRieTContent-Disposition: form-data; name="_IG_CSS_LINKS_"businesscontrols/styles/ig_uwg_styles/mm/ig_grid_opt.css|businesscontrols/styles/ig_uwg_styles/mm/ig_shared.css------WebKitFormBoundary3cR2BphPfiDBRieT--

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,169
    > char outfilename[FILENAME_MAX] = "C:\data.xls";
    Backslashes need to be quoted.

    Are you really opening the file you expect?

    Modern windows systems might prevent you from writing directly into the root directory.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2018
    Posts
    26
    Quote Originally Posted by Salem View Post
    > char outfilename[FILENAME_MAX] = "C:\data.xls";
    Backslashes need to be quoted.

    Are you really opening the file you expect?

    Modern windows systems might prevent you from writing directly into the root directory.


    @Salem Yeah that's the thing. I am not entirely sure. If the Excel file is exported by me clicking the "Export" button on the website, then shouldn't mimicking the POST request for it be enough to trigger the download of the file? Do I really need the whole download file code segment at the end? Thanks again by the way. When I download the file from the website, the file name is "data.xls".

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    3,880
    Hint: Salem meant you likely need "C:\\data.xls" instead of "C:\data.xls".

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  5. #5
    Registered User
    Join Date
    Jun 2018
    Posts
    26
    Quote Originally Posted by stahta01 View Post
    Hint: Salem meant you likely need "C:\\data.xls" instead of "C:\data.xls".

    Tim S.

    Thanks- I need to ask you the same question I asked Salem. If I mimicked the POST request sent after the "Export to Excel" button on the website is clicked manually, should an Excel file be generated without any further code (i.e. without me adding the write function and write data parts of my code)? I am trying to figure out if I may have made a mistake on the request itself somewhere.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    38,169
    The response that comes back should contain some indication of "here is the file you requested".

    I'm assuming that the Curl you wrote is what is necessary to receive a file download.

    You really ought to do some error checking.
    Code:
    fp = fopen(outfilename,"wb");
    if ( fp != NULL ) {
        curl_easy_setopt(myHandle, CURLOPT_WRITEFUNCTION, write_data);
        curl_easy_setopt(myHandle, CURLOPT_WRITEDATA, fp);
        res = curl_easy_perform(myHandle);
        fclose(fp);
    } else {
      perror("Unable to write to file");
    }
    /* always cleanup */
    curl_easy_cleanup(myHandle);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 07-20-2018, 10:19 PM
  2. Export data to excel
    By Marvin Gorres in forum C# Programming
    Replies: 6
    Last Post: 07-11-2013, 08:24 AM
  3. [C] Need help to export data to excel
    By daydreamin in forum C Programming
    Replies: 2
    Last Post: 05-06-2013, 03:37 AM
  4. Datagrid Export to MS Excel with C++ .NET
    By Gerudom in forum Windows Programming
    Replies: 3
    Last Post: 06-09-2006, 07:58 AM
  5. Replace "." (dot-comma) with "," (regular-comma) for MS Excel
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 03-20-2002, 01:39 AM

Tags for this Thread