question

itati-shop avatar image
0 Likes"
itati-shop asked ·

I need some help for the file upload feed API in PHP

Hello,

I need some help for the file upload feed API in PHP.

I just can't find an approach how to upload a file using the feed-API interface.

The aim is to upload a "csv" file that takes over the current stocks in eBay.

At the moment I am doing that with the FileExchange which will be discontinued on June 15th.

Maybe someone already has experience with it and can show me a PHP source code?

Many thanks for your help.


#### added: 15.Mai 2021 ####

The goal is to have a CSV file


For example, upload_file.csv:

----

Action (Siteid = Germany | Country = DE | Currency = EUR | Version = 835 | CC = UTF-8); Itemid; Quantity; Relationship; Relationship Details; Product: EAN; Customlabel

Revise; 31188022534; 15 ;;; 8335310347924; TM-37692

----


To upload to eBay via feed API.


First, the Create_Task is executed and returns a task number. (is working)


----

$ postdata = [

'feedtype' => 'lms_revise_fixed_price_item',

'Schemaversion' => '1149'

];

----


Then the file should be uploaded with


----

Curlopt_url => 'https://api.ebay.com/sell/feed/v1/task/task-1xx9/upload_file'

----


where the corresponding task number is used under Task-1xx9.


In the header, the same token has been used as the Create Task.


Result is:

Http / 1.1 100 Continue

HTTP / 1.1 500 Internal Server Error


and


{Errors ": [{" Errorid ": 160001," Domain ":" api_feed "," subdomain ":" Selling "," category ":" Application "," Message ":" There's a problem with an eBay internal System or Process. CONTACT eBay Developer Technical Support for Assistance. "}]}


And as an answer comes the following header:


----

Post / Sell / Feed / V1 / Task / Task-2-1444222119 / upload_file http / 1.1 Host: api.ebay.com ACCEPT-Encoding: Deflate, Gzip Authorization: Bearer V ^ 1.BlabLablaBlablaLA = X-eBay C-Marketplace -ID: eBay_en Accept: Application / JSON Content-Length: 55526 Content Type: Multipart / Form Data; Boundary = ------------------------ 7B48AB0D3D36F98D Expect: 100-Continue

----


Striking is that under Accept: Application / JSON stands.

The file length is correct.


Can it be that you can not load CSV files on German eBay, but only JSON files?


I am grateful for every tip ... :-)

feed-apiuploadfilelms_revise_fixed_price_item
· 4
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.

Ich habe (noch) nicht aufgegeben, aber ich habe gestern Stunden damit verbracht, erfolglos zu versuchen, es zum Laufen zu bringen.

1 Like 1 ·

For createTask you need a payload of

{

"feedType": "FX_LISTING",

"schemaVersion": "1.0"

}

For uploadFile you need Content-Type: multipart/form-data

Your CSV file should be OK.

In CURL I use -F "file=C:\XXX.csv"

That works.

0 Likes 0 ·
itati-shop avatar image itati-shop alvisinwales ·

Super ... Thanks for the info ... I tried the same time.


I have now seen that on eBay Seller-Cokpit Report has arrived the request (with the feed-type FX_Listing), but unfortunately no file is transferred. It seems that with PHP CURL no file replay from the server is possible.

Our scenario is such that the file is ready on a web server and should be uploaded to eBay. That does not seem to go with CURL. The request does not manage to load the file. :-(

0 Likes 0 ·

Perhaps that's not possible then. I only need to upload files from my own PC to replace the old programmatic upload using bulksell.ebay.co.uk.


0 Likes 0 ·
afridigems avatar image
0 Likes"
afridigems answered ·

The code you have provided is working on local PC but not working on live server.

Can you please suggest any modification?


See the response from my server.

task-40-1312321194string(595) "HTTP/1.1 100 Continue HTTP/1.1 500 Internal Server Error rlogid: t6pitaf%60btuf1%3D9whhpitaf%60btuf1*t2dao%28rbpv6713-1795f176c30-0x2355 x-ebay-client-tls-version: TLSv1.2 content-type: application/json content-length: 228 date: Wed, 12 May 2021 05:40:42 GMT x-envoy-upstream-service-time: 134 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."}]}" 


· 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 have exactly the same answer.

After all, I first get an answer (HTTP / 1.1 100 Continue) and then immediately an answer (HTTP / 1.1 500 Internal Server Error).

I find no mistake. And in the documentation is no longer.

What else could it be ???

0 Likes 0 ·
ordi-paris avatar image
0 Likes"
ordi-paris answered ·

Works fine. First create task, then upload file and later check result.

<?php


$curl = curl_init();


curl_setopt_array($curl, array(

CURLOPT_URL => 'https://api.ebay.com/sell/feed/v1/task/task-40-xxx7/upload_file',

CURLOPT_RETURNTRANSFER => true,

CURLOPT_ENCODING => '',

CURLOPT_MAXREDIRS => 10,

CURLOPT_SSL_VERIFYHOST=> 0,

CURLOPT_SSL_VERIFYPEER=> 0,

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("upload_file.csv")),'type' => 'form-data'),

CURLOPT_HTTPHEADER => array(

'Authorization: Bearer <your oauth token here>',

'X-EBAY-C-MARKETPLACE-ID: EBAY_US'

),

));


$response = curl_exec($curl);

var_dump($response);

curl_close($curl);

?>

· 4 ·
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.

You are awesome!

This works like a charm.

You saved my days.

Thanks

0 Likes 0 ·

The script works on Local PC, however, when I upload to live server, it does not work.

I have shared all the requests and responses in the forum, please check if there is any problem in the code?


https://forums.developer.ebay.com/questions/41609/selling-feed-api-uploadfile-works-from-local-pc-bu.html


Thanks

0 Likes 0 ·

many thanks for the help !!

I think that was the key ... I'll try it right away.

many thanks

0 Likes 0 ·

It may be that CSV files can not be uploaded, but only JSON?

0 Likes 0 ·
alvisinwales avatar image
0 Likes"
alvisinwales answered ·

@kipriiva I wish I could help but I got the same error when I used Content-Type: application/json so I tried with multipart/form-data (as per documentation). This gave 500 Internal Server Error for some of my attempts.


So still nothing is working.


I'm hoping that somebody who has actually got this to work will post some useful guidance.



· 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.

ja, es ist einfach nicht nachvollziehbar, wie ein Upload via API funktionieren soll.

Ich habe es aufgegeben und wir Suchen Alternativen.

Ggf. werden wir eBay in Richtung Amazon verlassen.

0 Likes 0 ·
alvisinwales avatar image
0 Likes"
alvisinwales answered ·

Unfortunately I can't help you with uploadFile in the Feed API. I've used eBay's REST APIs using Curl with no problems but so far I've had no joy with uploadFile (createTask works fine). I find eBay's documentation incomprehensible.


However, all is not lost as the new "File Exchange" in Seller Hub seems to work fine and uses the same input csv files.

Do Overview, Reports, Upload, Start Upload, Choose File.



· 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.

@ Is there any way you can share example REST API curl post for file upload.

I am getting

Unsupported or not specified media type

error

0 Likes 0 ·

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.