0

I tried to use Walmart API v4.2 to publish some items. I used "Bulk Item Setup" API method to create some feed. I used some types of ways to did it:

  • Send binary file (in the request body, for-data) with header "multipart/form-data" (this way was described in the Walmart API docs)
  • Send stringified object in the request body with header 'Content-Type': 'application/json',

Walmart API correctly returns me feedId. But all of these ways didn't work! After feed creating, I saw "Submitted" status at the Walmart Seller Center. But this status was changed after few minutes to "Error". At the error column I see "ERROR TYPE: Data Error" with a description "Malformed data. Please check data file to ensure it is formatted properly.java.lang.NullPointerException".

I use my backend NodeJs app to do it. I use Axios for making a request. My code example:

async createFeed(wdpId, wdpSecret, accessToken, feedsData) {
        try {
          const string = JSON.stringify(feedsData);
          const file = Buffer.from(string);

          const formData = new FormData();
          formData.append('file', file);

          const baseToken = WalmartService.getBaseAuthToken(wdpId,              wdpSecret);
          const options = {
            params: {
              feedType: 'MP_WFS_ITEM',
            },
            headers: {
               Authorization: baseToken,
              'WM_SEC.ACCESS_TOKEN': accessToken,
              'WM_QOS.CORRELATION_ID': uuidv4(),
              'WM_SVC.NAME': 'Walmart Marketplace',
               Accept: 'application/json',
              'Content-Type': 'application/json',
               ...formData.getHeaders(),
            },      
          };

          return (
            axios
              .post(`${process.env.WALMART_API_BASEURL}/feeds`, formData, options)
              .then((response) => {
                return response.data;
              })
              .catch((error) => {
                console.error(error.message);
                throw new BadRequestException('Walmart error, ', error.message);
              })
          );
        } catch (error) {
          throw new BadRequestException('Can not create listing');
        }
      }
  • Have you reached out to Walmart's support team? They would generally be able to more quickly identify *why* your data is "*malformed*" to them than we are. – esqew Oct 07 '21 at 17:12
  • 1
    Of course! I started a conversation with Walmart support. They answered me after few minutes. They said that my issue is very important and they sent my issue to the special technical team. It was about 3 or 4 days ago. That's all. – Festive MUXAUJL Oct 08 '21 at 18:40

1 Answers1

0

It is difficult to identify the exact issue based on the information you provided. Few things that you might want to check

  1. If you are appending/attaching a file (as I see it in the code), use Content-Type header as "multipart/form-data. Also, make sure the file name has a .json extension if you are sending data as a json string. If you don't use this, it might default to xml and you will get the same error as what you see.

  2. Try invoking the API using a rest client like Postman and verify if that call is successful.

  3. If you do want to send the data as HTTP body (instead of a file), that should work too with Content-Type as application/json. This has not been documented on their developer portal, but it works.

kushan85
  • 102
  • 1
  • 9
  • Thank you for the answer! I tried to go these ways, but never isn't working. 1. I sent a file with the filename ended .json. And I used the header "multipart/form-data" with "boundary..." (via formData method ...formData.getHeaders()) 2. I had got an equal error using postman 3. I found a similar issue on the "Stackoverflow" website and tried to send data in the request body with Content-Type as application/json, but I got an equal error. – Festive MUXAUJL Oct 08 '21 at 07:22
  • There may be something wrong with the file. If you open the file and make sure json format is correct. The reason I say is, there are thousands of partners integrated with these APIs without issues. Make sure you make it work using postman before trying to code it. – kushan85 Oct 13 '21 at 17:47
  • If you did this action success, I'll be very very thankful, if you will send me an example of a feed file. Thanks for your answer! – Festive MUXAUJL Oct 17 '21 at 12:18
  • @FestiveMUXAUJL, did you ever figure this out? I am facing this exact situation. – rom Apr 13 '22 at 04:32