0

I am attempting a go at updating quantities using the SubmitFeed action. Does anyone have experience with this? The error I am receiving is: 'Either Action or Operation query parameter must be present', but I do have 'Action=SubmitFeed' in the query string.

I have written four other functions (RequestReport, GetReportRequestList, GetReport, & GetFeedSubmissionList) that work perfectly. I imagine I am missing some cURL configuration options in order to post a file.

cURL options:

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded',
    'Content-MD5: '. $md5,
    'Transfer-Encoding: chunked',
)),
curl_setopt($ch, CURLINFO_HEADER_OUT => true);
curl_setopt($ch, CURLOPT_UPLOAD => true);
curl_setopt($ch, CURLOPT_PROTOCOLS => CURLPROTO_HTTPS);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_PORT , 443);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&', $url_parts));

Can anyone assist? Thank you.

danilo
  • 1
  • 3
  • Hi, can you please share all your parameters, what you have here is not enough to help. – mk_89 Apr 10 '13 at 11:01
  • What parameters? These are all I had for cURL. This may be of help to others: lookup AMTU. This is a much simpler method of submitting feeds. The AMTU worked after a few moments of writing code. – danilo Apr 18 '13 at 20:51

1 Answers1

0

In order to do a SubmitFeed call, you will have to use Content-Type: text/xml and use your XML feed as CURLOPT_POSTFIELDS. Your other option fields will have to go into the URL, as if this was a GET:

$ch = curl_init($url_with_fields);                   <-- change 1
curl_setopt($ch, CURLOPT_HTTPHEADER => array(
    'Content-Type: text/xml',                        <-- change 2
    'Content-MD5: '. $md5,
    'Transfer-Encoding: chunked',
)),
curl_setopt($ch, CURLINFO_HEADER_OUT => true);
curl_setopt($ch, CURLOPT_UPLOAD => true);
curl_setopt($ch, CURLOPT_PROTOCOLS => CURLPROTO_HTTPS);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_PORT , 443);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata);      <-- change 3

Note that this type of call also works for RequestReport, GetReportRequestList, GetReport, & GetFeedSubmissionList: just leave $xmldata empty in those cases.

Hazzit
  • 6,782
  • 1
  • 27
  • 46
  • you do not need to set CURLOPT_UPLOAD as it changes the method to PUT. All you need is POST – debianek Jun 07 '13 at 08:51
  • @debianek True. I tried to make minimal changes to his code and didn't notice the CURLOPT_UPLOAD in there. I think it should still work, though, but haven't actually tried. – Hazzit Jun 07 '13 at 13:02