Forum Academy Marketplace Showcase Pricing Features

How to get API connector to handle single values - when it is expecting a list

Hi,

I am working on Amazon MWS apis. The finance event api, takes order id as a parameter and returns a list of products in the order id. I initialized the API with an order with multiple products, so now the API connected expects a list there.
Bubble is able to parse the response as expected (in a list) when there are more than 1 products in an order. But when there is a single product - bubble does not treat is a list of 1.

How did you guys deal with such APIs?

Dummy API response (in XML) with multiple products:

  >  <ListFinancialEventsResponse xmlns="http://mws.amazonservices.com/Finances/2015-05-01">
>   <ListFinancialEventsResult>
>     <FinancialEvents>
>       <ProductAdsPaymentEventList/>
>       <RentalTransactionEventList/>
>       <PayWithAmazonEventList/>
>       <ServiceFeeEventList>
>         <ServiceFeeEvent>
>           <FeeList>
>             <FeeComponent>
>               <FeeType>MFNDeliveryServiceFee</FeeType>
>               <FeeAmount>
>                 <CurrencyAmount>0.0</CurrencyAmount>
>                 <CurrencyCode>INR</CurrencyCode>
>               </FeeAmount>
>             </FeeComponent>
>             <FeeComponent>
>               <FeeType>MFNPostageFee</FeeType>
>               <FeeAmount>
>                 <CurrencyAmount>-92.0</CurrencyAmount>
>                 <CurrencyCode>INR</CurrencyCode>
>               </FeeAmount>
>             </FeeComponent>
>           </FeeList>
>         </ServiceFeeEvent>
>       </ServiceFeeEventList>
>       <ServiceProviderCreditEventList/>
>       <SellerDealPaymentEventList/>
>       <SellerReviewEnrollmentPaymentEventList/>
>       <DebtRecoveryEventList/>
>       <ShipmentEventList>
>         <ShipmentEvent>
>           <ShipmentItemList>
>             <ShipmentItem>
>               <ItemChargeList>
>                 <ChargeComponent>
>                   <ChargeType>Principal</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>295.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>Tax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>GiftWrap</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>GiftWrapTax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>ShippingCharge</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>ShippingTax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>               </ItemChargeList>
>               <ItemFeeList>
>                 <FeeComponent>
>                   <FeeType>Commission</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>-21.8</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>FixedClosingFee</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>-11.5</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>GiftwrapCommission</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>ShippingHB</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>VariableClosingFee</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>               </ItemFeeList>
>               <OrderItemId>1180551221</OrderItemId>
>               <QuantityShipped>1</QuantityShipped>
>               <SellerSKU>ABCRF1000</SellerSKU>
>             </ShipmentItem>
>             <ShipmentItem>
>               <ItemChargeList>
>                 <ChargeComponent>
>                   <ChargeType>Principal</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>211.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>Tax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>GiftWrap</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>GiftWrapTax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>ShippingCharge</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>ShippingTax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>               </ItemChargeList>
>               <ItemFeeList>
>                 <FeeComponent>
>                   <FeeType>Commission</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>-19.61</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>FixedClosingFee</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>-11.5</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>GiftwrapCommission</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>ShippingHB</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>VariableClosingFee</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>               </ItemFeeList>
>               <OrderItemId>617522122</OrderItemId>
>               <QuantityShipped>1</QuantityShipped>
>               <SellerSKU>ABCIF1000</SellerSKU>
>             </ShipmentItem>
>             <ShipmentItem>
>               <ItemChargeList>
>                 <ChargeComponent>
>                   <ChargeType>Principal</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>211.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>Tax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>GiftWrap</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>GiftWrapTax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>ShippingCharge</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>ShippingTax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>               </ItemChargeList>
>               <ItemFeeList>
>                 <FeeComponent>
>                   <FeeType>Commission</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>-19.61</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>FixedClosingFee</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>-11.5</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>GiftwrapCommission</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>ShippingHB</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>VariableClosingFee</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>               </ItemFeeList>
>               <OrderItemId>181056975</OrderItemId>
>               <QuantityShipped>1</QuantityShipped>
>               <SellerSKU>ABCHF1000</SellerSKU>
>             </ShipmentItem>
>           </ShipmentItemList>
>           <AmazonOrderId>105-862-18027</AmazonOrderId>
>           <PostedDate>2017-06-21T05:29:20Z</PostedDate>
>           <MarketplaceName>Amazon.in</MarketplaceName>
>         </ShipmentEvent>
>       </ShipmentEventList>
>       <RetrochargeEventList/>
>       <SAFETReimbursementEventList/>
>       <GuaranteeClaimEventList/>
>       <ChargebackEventList/>
>       <LoanServicingEventList/>
>       <RefundEventList/>
>       <AdjustmentEventList/>
>       <PerformanceBondRefundEventList/>
>     </FinancialEvents>
>   </ListFinancialEventsResult>
>   <ResponseMetadata>
>     <RequestId>21aaf218-b1af-bc02e12f8b19</RequestId>
>   </ResponseMetadata>
> </ListFinancialEventsResponse>

Here’s the list I get to choose when I initialize this call -

Dummy response with 1 product:

> <ListFinancialEventsResponse xmlns="http://mws.amazonservices.com/Finances/2015-05-01">
>   <ListFinancialEventsResult>
>     <FinancialEvents>
>       <ProductAdsPaymentEventList/>
>       <RentalTransactionEventList/>
>       <PayWithAmazonEventList/>
>       <ServiceFeeEventList/>
>       <ServiceProviderCreditEventList/>
>       <SellerDealPaymentEventList/>
>       <SellerReviewEnrollmentPaymentEventList/>
>       <DebtRecoveryEventList/>
>       <ShipmentEventList>
>         <ShipmentEvent>
>           <ShipmentItemList>
>             <ShipmentItem>
>               <ItemChargeList>
>                 <ChargeComponent>
>                   <ChargeType>Principal</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>3559.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>Tax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>GiftWrap</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>GiftWrapTax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>ShippingCharge</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>                 <ChargeComponent>
>                   <ChargeType>ShippingTax</ChargeType>
>                   <ChargeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </ChargeAmount>
>                 </ChargeComponent>
>               </ItemChargeList>
>               <ItemFeeList>
>                 <FeeComponent>
>                   <FeeType>Commission</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>-32.12</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>FixedClosingFee</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>-11.5</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>GiftwrapCommission</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>ShippingHB</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>                 <FeeComponent>
>                   <FeeType>VariableClosingFee</FeeType>
>                   <FeeAmount>
>                     <CurrencyAmount>0.0</CurrencyAmount>
>                     <CurrencyCode>INR</CurrencyCode>
>                   </FeeAmount>
>                 </FeeComponent>
>               </ItemFeeList>
>               <OrderItemId>0929201171</OrderItemId>
>               <QuantityShipped>1</QuantityShipped>
>               <SellerSKU>ABC1000</SellerSKU>
>             </ShipmentItem>
>           </ShipmentItemList>
>           <AmazonOrderId>171-137-00147</AmazonOrderId>
>           <PostedDate>2017-06-14T09:34:15Z</PostedDate>
>           <MarketplaceName>Amazon.in</MarketplaceName>
>         </ShipmentEvent>
>       </ShipmentEventList>
>       <RetrochargeEventList/>
>       <SAFETReimbursementEventList/>
>       <GuaranteeClaimEventList/>
>       <ChargebackEventList/>
>       <LoanServicingEventList/>
>       <RefundEventList/>
>       <AdjustmentEventList/>
>       <PerformanceBondRefundEventList/>
>     </FinancialEvents>
>   </ListFinancialEventsResult>
>   <ResponseMetadata>
>     <RequestId>62fa22d8-69ac-c9cf335b23e1</RequestId>
>   </ResponseMetadata>
> </ListFinancialEventsResponse>

1 Like

Did you check out the new JSON based API? Selling Partner API.

I had the same issue with the XML returned by MWS (merchant web services API)

Is the payload different if there’s only one item VS multiple items?