question

swankypawsuk avatar image
0 Likes"
swankypawsuk asked

eBay Feed API -> uploadFile script working on local PC but not working on live server

Hi,

I am working with a freelance developer to migrate from File Exchange to Feed API.

The developer has created a solution (below) that works on a local server, but not on a live server. Both he and I have spent hours trying to debug the code but to no avail. He has posted the message below on StackOverflow.

Can anyone provide a point in the general direction to what the issue may be?

Many thanks,

Mark


--------------------------------------------------------------------------------------------------------------


Here is my script which uploads feed to ebay. The script working on local PC but when I upload to my live server, it does not work.

Here is my code.

public function createTask($feedType='FX_LISTING')
    {
        $link = "https://api.ebay.com/sell/feed/v1/task";
        //$appConfig = parse_ini_file("config.ini");
        
        //payload
        $payload = json_encode(array("schemaVersion"=>"1.0","feedType"=>"FX_LISTING"));


        //$appConfig['user_token'] = 'mehboob';
        $ch = curl_init($link);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Authorization:Bearer ' . $this->userToken,
            'Accept:application/json',
            'Content-Type:application/json',
            'X-EBAY-C-MARKETPLACE-ID: EBAY_US'
        ));
        curl_setopt($ch, CURLHEADER_SEPARATE, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        //scurl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
        curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
        $response = curl_exec($ch);
        $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
        $headers = substr($response, 0, $header_size);
        $body = substr($response, $header_size);
        $info = curl_getinfo($ch);  

        echo($body);
        curl_close($ch);

        $headers = explode("\r\n", $headers); // The seperator used in the Response Header is CRLF (Aka. \r\n) 

        $headers = array_filter($headers);

        $loc = basename(implode(preg_grep("/^location.*/", $headers)));
      return $loc;


    }
 


    public function uploadFile($taskID, $fName)
    {
          $link = "https://api.ebay.com/sell/feed/v1/task/$taskID/upload_file";
         $curl = curl_init();
        curl_setopt($curl, CURLINFO_HEADER_OUT, true);
        // curl_setopt($curl, CURLOPT_PROXY, '127.0.0.1:8888');
        curl_setopt_array($curl, array(
        CURLOPT_URL => $link,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_SSL_VERIFYHOST=> 1,
        CURLOPT_SSL_VERIFYPEER=> 1,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_HEADER => 1,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'POST',
        CURLOPT_POSTFIELDS => array('file'=> new CURLFILE(realpath($fName)),'type' => 'form-data'),
        CURLOPT_HTTPHEADER => array(
        'Authorization: Bearer ' . $this->userToken,
        'Content-Type: multipart/form-data',
        'X-EBAY-C-MARKETPLACE-ID: EBAY_US'
        ),
        
        )); 
        
        $response = curl_exec($curl);
        var_dump($response);

        curl_close($curl);

    }

Using the code as under:

$feedPath = __DIR__ . "/" ."feed.csv";
$taskID= createTask();
$uF = uploadFile($taskID,$feedPath);

The above code works fine on my local PC, creating task id and uploading file to ebay. But when I am uploading code on my server, it gets failed. I confirmed the path to the file on my server is OK. Also I am using the same version of PHP on my server.

Please see the following response I receives from Server.

string(595) "HTTP/1.1 100 Continue HTTP/1.1 500 Internal Server Error rlogid: t6pitaf%60btuf1%3D9vjdpitaf%60btuf1*or3ah%28rbpv6775-1795f5551e5-0x2340 x-ebay-client-tls-version: TLSv1.2 content-type: application/json content-length: 228 date: Wed, 12 May 2021 06:48:18 GMT x-envoy-upstream-service-time: 125 server: ebay-proxy-server x-ebay-pop-id: UFES2-LVSAZ01-api {"errors":[{"errorId":160001,"domain":"API_FEED","subdomain":"Selling","category":"APPLICATION","message":"There was a problem with an eBay internal system or process. Contact eBay Developer Technical Support for assistance."}]}"

The error says about "eBay internal error" but I don't think so. its due to some problem in the code.

The documentation to the above eBay service is as under: eBay Feed File - uploadFile documentation

Your cooperation in this context will be highly appreciated.

feed-apiupload
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

giuseppdivuol_0 avatar image
0 Likes"
giuseppdivuol_0 answered

I have the same problem...you solved?


https://api.ebay.com/sell/feed/v1/task/task-40-1214212894/upload_file
string(595) "HTTP/1.1 100 Continue HTTP/1.1 500 Internal Server Error rlogid: t6pitaf%60btuf1%3D9iptpitaf%60btuf1*sg1ua%28rbpv6762-1797ef6f870-0x2359 x-ebay-client-tls-version: TLSv1.2 content-type: application/json content-length: 228 date: Tue, 18 May 2021 10:13:07 GMT x-envoy-upstream-service-time: 880 server: ebay-proxy-server x-ebay-pop-id: UFES2-RNOAZ03-api {"errors":[{"errorId":160001,"domain":"API_FEED","subdomain":"Selling","category":"APPLICATION","message":"There was a problem with an eBay internal system or process. Contact eBay Developer Technical Support for assistance."}]}"

STATUS INVIO CSV

Array ( [url] => https://api.ebay.com/sell/feed/v1/task/task-40-1214212894/upload_file [content_type] => application/json [http_code] => 500 [header_size] => 367 [request_size] => 2555 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 4297.858234 [namelookup_time] => 1.9E-5 [connect_time] => 0.154295 [pretransfer_time] => 0.465175 [size_upload] => 3204798 [size_download] => 228 [speed_download] => 0 [speed_upload] => 745 [download_content_length] => 228 [upload_content_length] => 3204798 [starttransfer_time] => 4295.587359 [redirect_time] => 0 [redirect_url] => [primary_ip] => 209.140.129.1 [certinfo] => Array ( ) [primary_port] => 443 [local_ip] => 80.88.87.50 [local_port] => 26608 )
· 1
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Not solved. waiting for blessing.

0 Likes 0 ·
itati-shop avatar image
0 Likes"
itati-shop answered
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sandjwarehouse2 avatar image
0 Likes"
sandjwarehouse2 answered

I see you have:

var_dump($response);


but I think you need to see the request, including headers, and compare to the working local version.

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

i-got-to-have-that avatar image
0 Likes"
i-got-to-have-that answered

Hi


I am also struggling with this - to the point I cannot even get createtask to work.

I currently use file exchange programmatically for the last 7 years and do nearly 30000 revisions a day and maybe create/delete/refresh 15k listings a day.

But I only have 6 days to get this done.

With the createtask I am getting a 16002 error.

"The authentication scope https://api.ebay.com/oauth/api_scope is incorrect for 'feed_type' FX_LISTING"

What does this mean - I am using the OAUTH key (valoid for 60 mins)?


Has anyone got this fully working, including the upload of a file. I even paid for premium support to help me as my coding is a little rusty these days.

· 1
10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

I've just reproduced this error (but it's 160002) by incorrectly using Application access token instead of User access token. Try the latter.


0 Likes 0 ·
phyllisca97 avatar image
0 Likes"
phyllisca97 answered

I have same issue in the script if any solutions you have so please reply.


https://www.myaarpmedicare.guru/

10 |600 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.