none
Bulk Upload

    Question

  • Hi

    i am trying to update bids values with the Bulk Service of Bing API. I created a csv file with just one record. If i upload the file in the Bing Dashboard (Bulk Operations->Uploads), it works. The bid is changed. But when i use tha Bing API (php SDk, running PHP version 7.2), the upload is always on the state "inProgress" and the percentage complete stays in zero . 

    The response of the server (after 2 hours of the request) is :

    (
        [Errors] => 
        [ForwardCompatibilityMap] => stdClass Object
            (
            )

        [PercentComplete] => 0
        [RequestStatus] => InProgress
        [ResultFileUrl] => 
    )

    Thanks

    Wednesday, February 27, 2019 6:02 PM

Answers

  • The sample first compresses the file via the CompressFile helper. Are you using the same helper? 

    Note from one of our developers: "Depending on how the client compressed the file that .zip file might be invalid for us -  one easy way to validate the zip file is try to unzip it in the Windows Explorer." 

    If you have access to Windows Explorer please try that, and/or for this issue you are welcome to email us the ZIP file. You can reach me via eric.urban@microsoft.com.

    Best regards,

    Eric

    • Marked as answer by f79 Monday, March 4, 2019 3:33 PM
    Monday, March 4, 2019 3:09 PM
    Owner

All replies

  • Can you please share details e.g., SOAP request/response and timestamp? Are you using production or sandbox?

    Thank you,

    Eric

    Thursday, February 28, 2019 3:48 PM
    Owner
  • Hi Eric

    Thanks for the response. 

    First i ask for a bulk upload url. (GetBulkUploadUrl). I receive an URL. Everything OK



    After i send the file using PHP SDK example that is in git HUB



    function UploadFile($uploadUrl, $filePath)
    {
        
        date_default_timezone_set("UTC");
        $ch = curl_init($uploadUrl);

         
        if(!isset($GLOBALS['AuthorizationData']))
        {
            throw new Exception("AuthorizationData is not set.");
        }
        
        // Set the authorization headers.
        if(isset($GLOBALS['AuthorizationData']->Authentication) && isset($GLOBALS['AuthorizationData']->Authentication->Type))
        {
            $authorizationHeaders = array();
            $authorizationHeaders[] = "DeveloperToken: " . $GLOBALS['AuthorizationData']->DeveloperToken;
            $authorizationHeaders[] = "CustomerId: " . $GLOBALS['AuthorizationData']->CustomerId;
            $authorizationHeaders[] = "CustomerAccountId: " . $GLOBALS['AuthorizationData']->AccountId;
            $authorizationHeaders[] = "Content-Type: multipart/form-data;";

            if(isset($GLOBALS['AuthorizationData']->Authentication->OAuthTokens)) 
            {
                $authorizationHeaders[] = "AuthenticationToken: " . $GLOBALS['AuthorizationData']->Authentication->OAuthTokens->AccessToken;
            }
        }
        else
        {
            throw new Exception("Invalid Authentication Type.");
        }

        curl_setopt($ch, CURLOPT_HTTPHEADER, $authorizationHeaders);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        //curl_setopt($ch, CURLOPT_SAFE_UPLOAD, TRUE);

        
        $file = curl_file_create($filePath, "application/zip", "payload.zip");
        curl_setopt($ch, CURLOPT_POSTFIELDS, array("payload" => $file));

        $result = curl_exec($ch);
        $info = curl_getinfo($ch);
        $http_code = $info['http_code'];

              
        if (curl_errno($ch))
        {
            print "Curl Error: " . curl_error($ch) . "\n";
        }
        else
        {
            print_r($result);
            print_r($info);
            print "HTTP Result Code:\n" . $http_code . "\n";

        }
                 
        curl_close($ch);

        if($http_code == 200){
            return true;
        }
        else {
            return false;
        }
    }




    At this point everything ok, there is no error in curl response.

    Then i use GetBulkUploadStatus method to watch the state of the upload. here is the request and response

    REQUEST:::

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"    xmlns:ns1="https://bingads.microsoft.com/CampaignManagement/v12">
       <SOAP-ENV:Header>
          <ns1:CustomerAccountId>######</ns1:CustomerAccountId>
          <ns1:CustomerId>####</ns1:CustomerId>
          <ns1:DeveloperToken>####</ns1:DeveloperToken>
          <ns1:UserName />
          <ns1:Password />
          <ns1:AuthenticationToken>######</ns1:AuthenticationToken>
       </SOAP-ENV:Header>
       <SOAP-ENV:Body>
          <ns1:GetBulkUploadStatusRequest>
             <ns1:RequestId>9520bfd3-b42c-4c00-9921-46c295057c16</ns1:RequestId>
          </ns1:GetBulkUploadStatusRequest>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>


    RESPONSE:

    <?xml version="1.0" encoding="UTF-8"?>
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
       <s:Header>
          <h:TrackingId xmlns:h="https://bingads.microsoft.com/CampaignManagement/v12">b69cf60c-695a-47ba-b790-a0b4e38fa06a</h:TrackingId>
       </s:Header>
       <s:Body>
          <GetBulkUploadStatusResponse xmlns="https://bingads.microsoft.com/CampaignManagement/v12">
             <Errors xmlns:i="http://www.w3.org/2001/XMLSchema-instance" i:nil="true" />
             <ForwardCompatibilityMap xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" />
             <PercentComplete>0</PercentComplete>
             <RequestStatus>InProgress</RequestStatus>
             <ResultFileUrl xmlns:i="http://www.w3.org/2001/XMLSchema-instance" i:nil="true" />
          </GetBulkUploadStatusResponse>
       </s:Body>
    </s:Envelope>



    Time: Thursday, February 28, 2019 5:03:00 PM GMT+00:00

    Historical Performance: Never worked.

    Frequency: Every time

    Environment: Production



    Thanks



    • Edited by f79 Thursday, February 28, 2019 5:34 PM
    Thursday, February 28, 2019 5:27 PM
  • The error we found in the logs says "End of Central Directory record could not be found". Per the documentation:

    "The content type must be multipart/form-data. UTF-8 files must include the byte order mark (BOM). The ZIP-compressed upload should contain one file formatted as either Csv or Tsv. The ZIP file must be properly structured, including an end of central directory record."

    Also further down in the doc:

    "If compressed it must be formatted as ZIP with the corresponding extension. The file size limit for upload in production is 100MB and up to 4 million rows."

    Could you please double check? 

    Best regards,

    Eric

    Saturday, March 2, 2019 12:56 AM
    Owner
  • hi Eric thanks for the reply

    I think i am doing everything ok.


    The content type is multipart/form-data:

            $authorizationHeaders[] = "Content-Type: multipart/form-data;";
             curl_setopt($ch, CURLOPT_HTTPHEADER, $authorizationHeaders);

    I saved the csv in utf8 with BOM and the zip contains a Csv. I grab the CSv and create a new zip file with curl_file_create function as it is in samples and then it send it via curl

        $file = curl_file_create($csvFile, "application/zip", "payload.zip");

        curl_setopt($ch, CURLOPT_POSTFIELDS, array("payload" => $file));

    The size limit its not a problem. It only have 2 Kb.


    Monday, March 4, 2019 2:44 PM
  • The sample first compresses the file via the CompressFile helper. Are you using the same helper? 

    Note from one of our developers: "Depending on how the client compressed the file that .zip file might be invalid for us -  one easy way to validate the zip file is try to unzip it in the Windows Explorer." 

    If you have access to Windows Explorer please try that, and/or for this issue you are welcome to email us the ZIP file. You can reach me via eric.urban@microsoft.com.

    Best regards,

    Eric

    • Marked as answer by f79 Monday, March 4, 2019 3:33 PM
    Monday, March 4, 2019 3:09 PM
    Owner
  • Ok, i am trying with linux system. I tried with MS Windows and it works.

    After that i install another lib in linux and now it works here too. Thank you very much

    Monday, March 4, 2019 3:33 PM
  • Thanks for confirming!
    Monday, March 4, 2019 3:39 PM
    Owner
  • What was the library you used? 
    Friday, March 15, 2019 12:46 AM