SubmitFeed Sample Java is not working


Hello, I’m new to MWS. I’m trying to build submitfeed API and I’m using sample java code to test it but in ---- from line — method.setEntity( new InputStreamEntity(sfr.getFeedContent() , -1) ); — it is throwing exception. Please need some quick help on this. Please let me know what causing this issue.
Output getting -
Caught Exception: null
Response Status Code: -1
Error Code: null
Error Type: null
Request ID: null
XML: nullResponseHeaderMetadata: null


Since you didn’t provide more information the only help I can give is that there is something missing on your SubmitFeedRequest object. From the exception it looks like its the feedContent property is null.


Thanks for the quick reply. Yes, I’m not sending feedContent value. I’m pasting the java code where I used my sample values to get a result. As per your comment I tried to uncomment feedContent type it is not finding FileInputStream class. Please suggest further.


  • Copyright 2009 Amazon Services.
  • Licensed under the Apache License, Version 2.0 (the “License”);
  • You may not use this file except in compliance with the License.
  • You may obtain a copy of the License at:
  • This file is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
  • CONDITIONS OF ANY KIND, either express or implied. See the License for the
  • specific language governing permissions and limitations under the License.

  • Marketplace Web Service Java Library
  • API Version: 2009-01-01
  • Generated: Wed Feb 18 13:28:48 PST 2009


package com.amazonaws.mws.samples;

import java.util.Arrays;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.ArrayList;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import com.amazonaws.mws.;
import com.amazonaws.mws.model.
import com.amazonaws.mws.mock.MarketplaceWebServiceMock;


  • Submit Feed Samples

public class SubmitFeedSample {

 * Just add a few required parameters, and try the service Submit Feed
 * functionality
 * @param args
 *            unused
 * @param args
public static void main(String... args) {

     * Access Key ID and Secret Access Key ID, obtained from:
    final String accessKeyId = "0PB842ExampleN4ZTR2";
    final String secretAccessKey = "kWcrlEXAMPLEM/LtmEENI/aVmYvHNif5zB+d9+ct";

    final String appName = "IR";
    final String appVersion = "12c";

    MarketplaceWebServiceConfig config = new MarketplaceWebServiceConfig();

     * Uncomment to set the appropriate MWS endpoint.
    // US
    // UK
    // config.setServiceURL("");
    // Germany
    // config.setServiceURL("");
    // France
    // config.setServiceURL("");
    // Italy
    // config.setServiceURL("");
    // Japan
    // config.setServiceURL("");
    // China
    // config.setServiceURL("");
    // Canada
    // config.setServiceURL("");
    // India
    // config.setServiceURL("");

     * You can also try advanced configuration options. Available options are:
     *  - Signature Version
     *  - Proxy Host and Proxy Port
     *  - User Agent String to be sent to Marketplace Web Service

     * Instantiate Http Client Implementation of Marketplace Web Service        

    MarketplaceWebService service = new MarketplaceWebServiceClient(
            accessKeyId, secretAccessKey, appName, appVersion, config);

     * Setup request parameters and uncomment invoke to try out sample for
     * Submit Feed

     * Marketplace and Merchant IDs are required parameters for all
     * Marketplace Web Service calls.
    final String merchantId = "A1XExample5E6";
    final String sellerDevAuthToken = "amzn.mws.4ea38b7b-f563-7709-4bae-87aeaEXAMPLE";
    // marketplaces to which this feed will be submitted; look at the
    // API reference document on the MWS website to see which marketplaces are
    // included if you do not specify the list yourself
    final IdList marketplaces = new IdList(Arrays.asList(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    SubmitFeedRequest request = new SubmitFeedRequest();


    // MWS exclusively offers a streaming interface for uploading your
    // feeds. This is because
    // feed sizes can grow to the 1GB+ range - and as your business grows
    // you could otherwise
    // silently reach the feed size where your in-memory solution will no
    // longer work, leaving you
    // puzzled as to why a solution that worked for a long time suddenly
    // stopped working though
    // you made no changes. For the same reason, we strongly encourage you
    // to generate your feeds to
    // local disk then upload them directly from disk to MWS via Java -
    // without buffering them in Java
    // memory in their entirety.
    // Note: MarketplaceWebServiceClient will not retry a submit feed request
    // because there is no way to reset the InputStream from our client. 
    // To enable retry, recreate the InputStream and resubmit the feed
    // with the new InputStream. 
    // request.setFeedContent( new FileInputStream("my-feed.xml" /*or
    // "my-flat-file.txt" if you use flat files*/);

    invokeSubmitFeed(service, request);


 * Submit Feed request sample Uploads a file for processing together with
 * the necessary metadata to process the file, such as which type of feed it
 * is. PurgeAndReplace if true means that your existing e.g. inventory is
 * wiped out and replace with the contents of this feed - use with caution
 * (the default is false).
 * @param service
 *            instance of MarketplaceWebService service
 * @param request
 *            Action to invoke
public static void invokeSubmitFeed(MarketplaceWebService service,
        SubmitFeedRequest request) {
    try {
        System.out.println("request: "+request);
        SubmitFeedResponse response = service.submitFeed(request);

        System.out.println("SubmitFeed Action Response");

        System.out.print("    SubmitFeedResponse");
        if (response.isSetSubmitFeedResult()) {
            System.out.print("        SubmitFeedResult");
            SubmitFeedResult submitFeedResult = response
            if (submitFeedResult.isSetFeedSubmissionInfo()) {
                System.out.print("            FeedSubmissionInfo");
                FeedSubmissionInfo feedSubmissionInfo = submitFeedResult
                if (feedSubmissionInfo.isSetFeedSubmissionId()) {
                    System.out.print("                FeedSubmissionId");
                    System.out.print("                    "
                            + feedSubmissionInfo.getFeedSubmissionId());
                if (feedSubmissionInfo.isSetFeedType()) {
                    System.out.print("                FeedType");
                    System.out.print("                    "
                            + feedSubmissionInfo.getFeedType());
                if (feedSubmissionInfo.isSetSubmittedDate()) {
                    System.out.print("                SubmittedDate");
                    System.out.print("                    "
                            + feedSubmissionInfo.getSubmittedDate());
                if (feedSubmissionInfo.isSetFeedProcessingStatus()) {
                    .print("                FeedProcessingStatus");
                    System.out.print("                    "
                            + feedSubmissionInfo.getFeedProcessingStatus());
                if (feedSubmissionInfo.isSetStartedProcessingDate()) {
                    .print("                StartedProcessingDate");
                    .print("                    "
                            + feedSubmissionInfo
                if (feedSubmissionInfo.isSetCompletedProcessingDate()) {
                    .print("                CompletedProcessingDate");
                    System.out.print("                    "
                            + feedSubmissionInfo
        if (response.isSetResponseMetadata()) {
            System.out.print("        ResponseMetadata");
            ResponseMetadata responseMetadata = response
            if (responseMetadata.isSetRequestId()) {
                System.out.print("            RequestId");
                System.out.print("                "
                        + responseMetadata.getRequestId());

    } catch (MarketplaceWebServiceException ex) {

        System.out.println("Caught Exception: " + ex.getMessage());
        System.out.println("Response Status Code: " + ex.getStatusCode());
        System.out.println("Error Code: " + ex.getErrorCode());
        System.out.println("Error Type: " + ex.getErrorType());
        System.out.println("Request ID: " + ex.getRequestId());
        System.out.print("XML: " + ex.getXML());
        System.out.println("ResponseHeaderMetadata: " + ex.getResponseHeaderMetadata());

“C:\Program Files\Java\jdk1.8.0_144\bin\javaw.exe” -server -classpath C:\JDeveloper\mywork_12.2.1.3\AmazonSeller.adf;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\AMZSFeedsClientLibraryService\classes;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\commons-codec-1.3\commons-codec-1.3.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\commons-httpclient-3.0.1\commons-httpclient-3.0.1.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\commons-logging-1.1\commons-logging-1.1.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\httpclient-4.2\httpclient-4.2.6.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\httpcore-4.2\httpcore-4.2.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\jaxb-ri-2.1\activation.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\jaxb-ri-2.1\jaxb-api.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\jaxb-ri-2.1\jaxb-impl.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\jaxb-ri-2.1\jaxb-xjc.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\jaxb-ri-2.1\jsr173_1.0_api.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\third-party\log4j-1.2.14\log4j-1.2.14.jar;C:\JDeveloper\mywork_12.2.1.3\AmazonSeller\dist\MaWSJavaClientLibrary-1.1.jar\Users*****\AppData\Local\Temp\trustStore1067076711832250244.jks com.amazonaws.mws.samples.SubmitFeedSample
request: com.amazonaws.mws.model.SubmitFeedRequest@358ee631
Caught Exception: null
Response Status Code: -1
Error Code: null
Error Type: null
Request ID: null
XML: nullResponseHeaderMetadata: null
Picked up _JAVA_OPTIONS: -Xmx1024m
Process exited with exit code 0.


Additionally, in feedContent type it is basically sending the feed xml file but in my case I’m not going to send the feed xml file like that. Please provide some more information.


This call will fail unless you provide a file. Which feed are you trying to use?


I’m using POST_ORDER_FULFILLMENT_DATA. Using this code to get ContentMD5Value and Signature mainly. Is this just a filename or it will look for that file also. Please assist further.


Not sure why you need those things. However you need to provide a file or else it will fail trying to attempt to make the call. You can get those via scratchpad. Scratchpad hits production data so be very careful with what you are testing.


Ok, I think I should ask the 1st question 1st and then it will make more sense. As I mentioned I’m totally new to MWS and trying to send shipment order information to amazon using their API. So, on documentation I found, I to have build a REST API like below - So what I found is ContentMD5Value and Signature, these two I have to calculate and pass and rest of the values I think I will get from developer access. Please let me know whether the understanding is correct or not. If you can give me a sample API to see how that looks will be great as well. I need to form that API correctly and then I will use Oracle SOA Suite to call the API.

POST /Feeds/2009-01-01 HTTP/1.1
Content-Type: x-www-form-urlencoded



Why not just leverage that Java client library to do this work for you?


Yes, that’s why I started going through that to create the API for me and there I got stuck with that error. So, from your comment I feel like I’m looking at the correct place and now I’ve to put that filename to get the API generated. Another challenge is I’m yet to get the developer access, so not sure what would be final output of that java class once I provide my credentials details. So, that java class will give me the correct API formed which I need to use, right?


Are you creating your own API or are you trying to access Amazon’s API (MWS)?


Amazon’s API (MWS)


The client library includes mock objects. They aren’t all complete however the API documentation itself has a sample of the response. Since you don’t have credentials you won’t be able to make the call even if you add the xml. However you could create a test call that instead of reaching Amazon it just replies with the sample XML. If done properly you could have a working mock environment so that you can get things ready until you receive the credentials.

This is from the

Successful submitted response:

<SubmitFeedResponse xmlns="">


Sure, I will look into those mock objects. So, can you please confirm whether this sample codes actually submit the feed? I basically want to use these sample codes just to generate correct Amazon MWS APIs and then will call it from Oracle SOA suite. Can I use that code just to get the API and not to actually submit from inside the java code?


Well its not that simple. Since you are trying to reverse engineer this and not use the Java client. The main issue I’ve seen people run into when doing this is that the request has to be signed. Good place to try and test this is using scratchpad which I posted on an earlier reply. But without dev credentials you can’t do anything.


Yes, let me get that 1st and if I have anymore roadblocks after that, I will post accordingly. Thanks for your help and suggestions so far.


Hello, finally I got the credentials and used scratchpad to generate the signature and contentMD5value. What I see is contentMD5value is same each time but signature is getting changed. Can you please confirm whether I can use same signature for all the APIs or that needs to be generated each time? Please confirm on this.


The signature needs to be generated for each call as it is the encoded value of the API call which includes the API name, action, time stamp, access key, etc. Even for the same API and action, the signature will change as the time stamp will change.


Thanks for the update. Do you have any java code suggestion to generate the signature? I will use MD5value from scratchpad but do you think I should generate that as well and what is timestamp format it they are using?


Look at the request details in scratchpad. It has the exact timestamp format.