How to send CSV file in feed via the MWS API?

Countries

Read only
Australia
Belgium
Brazil
Canada
Egypt
France
Germany
India
Italy
Japan
Mexico
Netherlands
Poland
Saudi Arabia
Singapore
Spain
Sweden
Turkey
United Arab Emirates
United Kingdom
United States
United Kingdom
imgSign in
user profile
Seller_s0q4eT0IHyb5N

How to send CSV file in feed via the MWS API?

Hi,

I’m confused as to how you are supposed to submit “Upload via file” feeds via the API. Here is my trimmed down code:

my $xml_vals = {
    'Action'               => "SubmitFeed",
    'ReportType'           => "_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_",
    'AWSAccessKeyId'       => $cfg->{access_key_id},
    'SellerId'             => $cfg->{merchant_id},
    'MarketplaceId.ID.1'   => $cfg->{marketplace_id},
    'Version'              => '2009-01-01',
    'SignatureVersion'     => 2,
    'FeedType'				=> "_POST_PRODUCT_DATA_",
    'SignatureMethod'      => 'HmacSHA256',
    'Timestamp'            => $now,
    'FeedContent'		   => qq|TemplateType=fptcustom	Version=2018.1114	TemplateSignature=QUNDRVNTT1JZX09SX1BBUlRfT1JfU1VQUExZLExVR0dBR0UsVE9ZU19BTkRfR0FNRVMsQ09NUFVURVJfRFJJVkVfT1JfU1RPUkFHRSxQSE9ORV9BQ0NFU1NPUlk=	The top 3 rows are for Amazon.com use only. Do not modify or delete the top 3 rows.									Images									Variation				Basic						Discovery																											Product Enrichment																																																																																																													Dimensions																				Fulfillment										Compliance																																														Offer																										b2b
Feed Product Type	Seller SKU	Brand Name	Item Name (aka Title)	Product ID	Product ID Type	Manufacturer	Manufacturer Part Number	Recommended Browse Nodes	Quantity	Standard Price	Main Image URL	Swatch Image Url	Other Image URL	Other Image URL	Other Image URL	Other Image URL	Other Image URL	Other Image URL	Other Image URL	Other Image URL	Parentage	Relationship Type	Parent SKU	Variation Theme	Update Delete	Product Description	Language	edition	model	GTIN Exemption Reason	Key Product Features	Key Product Features	Key Product Features	Key Product Features	Key Product Features	Search Terms	Search Terms	Search Terms	Search Terms	Search Terms	Catalog Number	Platinum Keywords	Platinum Keywords	Platinum Keywords	Platinum Keywords	Platinum Keywords	Department	target_audience_base1	target_audience_base2	target_audience_base3	target_audience_base4	target_audience_base5	target_audience_keywords1	target_audience_keywords2	target_audience_keywords3	target_audience_keywords4	target_audience_keywords5	Box Contents	Form Factor	Product Finish Type	Skill Level	Water Resistance Level	Colour	Colour Map	Size	Size Map	Hardware Platform	Available Audio Output Effects	Hard Drive Size	Hard Drive Size	Hard Drive Size	Hard Drive Size	Hard Drive Size	Hard Drive Size	Hard Drive Size	Hard Drive Size	Manufacturer Warranty Description	Material Type	Hard Drive Interface	Hard Drive Interface	Hard Drive Interface	Hard Drive Interface	Hard Drive Interface	Product Care Instructions	Media Types	Media Types	Media Types	Media Types	Media Types	Is Assembly Required	Operating Systems	Compatible Devices	Minimum Age Recommendation	Maximum Age Recommendation	Compatible Mountings	Maximum Weight Recommendation	Target Gender	Special Features	Special Features	Special Features	Special Features	Special Features	Subject Character	Subject	Cable Length	Material Composition	Cable Length Unit Of Measure	Scale	Connector Gender	Connector Gender	Connector Gender	Connector Gender	Connector Gender	Rail Gauge	Remote Control Technology	Package Content Type	Engine Type	Recommended Use	Educational Value	Model Name	Number Of Players	Number Of Pieces	Handle Height	Handle Height Unit Of Measure	Data Transfer Rate	Buffer Size	Buffer Size Unit Of Measure	Lithium Battery Voltage	Battery Average Life Talk Time	Battery Average Life Talk Time Unit Of Measure	Component Memory Storage Capacity	Memory Storage Capacity Unit Of Measure	Energy Specifications Standard	Energy Specifications Standard	Energy Specifications Standard	Energy Specifications Standard	Energy Specifications Standard	Power Source	Voltage	Power Plug Type	Battery Average Life	Battery Average Life Unit Of Measure	Battery Power	Screen Size	Display Size Unit Of Measure	Network Connectivity Technology	Wireless Technology Type	Wireless Technology Type	Wireless Technology Type	Wireless Technology Type	Wireless Technology Type	Connector Types	Connector Types	Connector Types	Connector Types	Connector Types	Flash Memory Installed	Flash Memory Installed Size Unit Of Measure	Collection	Year of the model	Casing	Number of wheels	Lock type	style_name	Unit Count Unit	unit_count_type	Shipping Weight	Website Shipping Weight Unit Of Measure	Item Height	Item Length	Item Width	Item Length Unit Of Measure	Display Weight	Item Display Weight Unit Of Measure	Display Volume	Item Display Volume Unit Of Measure	Display Length	Item Display Length Unit Of Measure	Speaker Diameter	Item Display Diameter Unit Of Measure	Volume or capacity	Volume Capacity Name Unit Of Measure	Item Width Unit Of Measure	Item Height Unit Of Measure	Item Dimensions Unit Of Measure	Item Diameter Unit Of Measure	Fulfillment Centre ID	Package Height	Package Width	Package Length	Package Length Unit Of Measure	Package Weight	Package Weight Unit Of Measure	Package Dimensions Unit Of Measure	Unit of measure of package weight	Package Width Unit Of Measure	EU Toys Safety Directive Age-specific warning	EU Toys Safety Directive Non-Age-specific warning	EU Toys Safety Directive language warning	Legal Disclaimer Description	Safety Warning	Country/Region Of Origin	Tuner Type	Item Weight	item_weight_unit_of_measure	Batteries are Included	Is this product a battery or does it utilise batteries?	Battery type/size	Battery type/size	Battery type/size	Number of batteries	Number of batteries	Number of batteries	Watt hours per battery	Number of Lithium-ion Cells	Number of Lithium Metal Cells	Lithium content (grams)	Lithium Battery Packaging	Certification	Battery composition	Battery weight (grams)	battery_weight_unit_of_measure	lithium_battery_energy_content_unit_of_measure	lithium_battery_weight_unit_of_measure	Applicable Dangerous Goods Regulations	Applicable Dangerous Goods Regulations	Applicable Dangerous Goods Regulations	Applicable Dangerous Goods Regulations	Applicable Dangerous Goods Regulations	UN number	Safety Data Sheet (SDS) URL	Volume	item_volume_unit_of_measure	fabric_type	Flash point (°C)?	region_of_origin	Product fiche	Energy efficiency label	Country/Region of declaration	Categorization/GHS pictograms (select all that apply)	Categorization/GHS pictograms (select all that apply)	Categorization/GHS pictograms (select all that apply)	Currency	Condition Type	Offer Condition Note	Launch Date	Handling Time	Release Date	Restock Date	Sale Price	Sale From Date	Sale End Date	Number of Items	Stop Selling Date	Max Aggregate Ship Quantity	Product Tax Code	Can Be Gift Messaged	Is Gift Wrap Available?	Is Discontinued by Manufacturer	Recommended Retail Price	WEEE Tax Value	WEEE Tax Value Unit of Measure	item_package_quantity	Max Order Quantity	Merchant Shipping Group	Offering Release Date	Scheduled Delivery SKU List	RRP	Business Price	Quantity Price Type	Quantity Lower Bound 1	Quantity Price 1	Quantity Lower Bound 2	Quantity Price 2	Quantity Lower Bound 3	Quantity Price 3	Quantity Lower Bound 4	Quantity Price 4	Quantity Lower Bound 5	Quantity Price 5	National Stock Number	United Nations Standard Products and Services Code	Pricing Action
feed_product_type	item_sku	brand_name	item_name	external_product_id	external_product_id_type	manufacturer	part_number	recommended_browse_nodes	quantity	standard_price	main_image_url	swatch_image_url	other_image_url1	other_image_url2	other_image_url3	other_image_url4	other_image_url5	other_image_url6	other_image_url7	other_image_url8	parent_child	relationship_type	parent_sku	variation_theme	update_delete	product_description	language_value	edition	model	gtin_exemption_reason	bullet_point1	bullet_point2	bullet_point3	bullet_point4	bullet_point5	generic_keywords1	generic_keywords2	generic_keywords3	generic_keywords4	generic_keywords5	catalog_number	platinum_keywords1	platinum_keywords2	platinum_keywords3	platinum_keywords4	platinum_keywords5	department_name	target_audience_base1	target_audience_base2	target_audience_base3	target_audience_base4	target_audience_base5	target_audience_keywords1	target_audience_keywords2	target_audience_keywords3	target_audience_keywords4	target_audience_keywords5	included_components	form_factor	finish_type	skill_level	water_resistance_level	color_name	color_map	size_name	size_map	hardware_platform	audio_output_effects	hard_disk_size1	hard_disk_size2	hard_disk_size3	hard_disk_size4	hard_disk_size5	hard_disk_size6	hard_disk_size7	hard_disk_size8	warranty_description	material_type	hard_disk_interface1	hard_disk_interface2	hard_disk_interface3	hard_disk_interface4	hard_disk_interface5	care_instructions	media_type_base1	media_type_base2	media_type_base3	media_type_base4	media_type_base5	is_assembly_required	operating_system	compatible_devices	mfg_minimum	mfg_maximum	compatible_mountings	maximum_weight_recommendation	target_gender	special_features1	special_features2	special_features3	special_features4	special_features5	subject_character	unknown_subject	cable_length	material_composition	cable_length_unit_of_measure	scale_name	connector_gender1	connector_gender2	connector_gender3	connector_gender4	connector_gender5	rail_gauge	remote_control_technology	package_content_type	engine_type	recommended_uses_for_product	educational_objective	model_name	number_of_players	number_of_pieces	handle_height	handle_height_unit_of_measure	data_transfer_rate	buffer_size	buffer_size_unit_of_measure	lithium_battery_voltage	battery_average_life_talk_time	battery_average_life_talk_time_unit_of_measure	memory_storage_capacity	memory_storage_capacity_unit_of_measure	specification_met1	specification_met2	specification_met3	specification_met4	specification_met5	power_source_type	voltage	power_plug_type	battery_average_life	battery_average_life_unit_of_measure	battery_power	display_size	display_size_unit_of_measure	connectivity_technology	wireless_communication_technology1	wireless_communication_technology2	wireless_communication_technology3	wireless_communication_technology4	wireless_communication_technology5	connector_type1	connector_type2	connector_type3	connector_type4	connector_type5	flash_memory_installed_size	flash_memory_installed_size_unit_of_measure	collection_name	model_year	shell_type	number_of_wheels	lock_type	style_name	unit_count	unit_count_type	website_shipping_weight	website_shipping_weight_unit_of_measure	item_height	item_length	item_width	item_length_unit_of_measure	item_display_weight	item_display_weight_unit_of_measure	item_display_volume	item_display_volume_unit_of_measure	item_display_length	item_display_length_unit_of_measure	item_display_diameter	item_display_diameter_unit_of_measure	volume_capacity_name	volume_capacity_name_unit_of_measure	item_width_unit_of_measure	item_height_unit_of_measure	item_dimensions_unit_of_measure	item_diameter_unit_of_measure	fulfillment_center_id	package_height	package_width	package_length	package_length_unit_of_measure	package_weight	package_weight_unit_of_measure	package_dimensions_unit_of_measure	package_height_unit_of_measure	package_width_unit_of_measure	eu_toys_safety_directive_age_warning	eu_toys_safety_directive_warning	eu_toys_safety_directive_language	legal_disclaimer_description	safety_warning	country_of_origin	tuner_technology	item_weight	item_weight_unit_of_measure	are_batteries_included	batteries_required	battery_type1	battery_type2	battery_type3	number_of_batteries1	number_of_batteries2	number_of_batteries3	lithium_battery_energy_content	number_of_lithium_ion_cells	number_of_lithium_metal_cells	lithium_battery_weight	lithium_battery_packaging	external_testing_certification	battery_cell_composition	battery_weight	battery_weight_unit_of_measure	lithium_battery_energy_content_unit_of_measure	lithium_battery_weight_unit_of_measure	supplier_declared_dg_hz_regulation1	supplier_declared_dg_hz_regulation2	supplier_declared_dg_hz_regulation3	supplier_declared_dg_hz_regulation4	supplier_declared_dg_hz_regulation5	hazmat_united_nations_regulatory_id	safety_data_sheet_url	item_volume	item_volume_unit_of_measure	fabric_type	flash_point	region_of_origin	product_efficiency_image_url	energy_efficiency_image_url	country_string	ghs_classification_class1	ghs_classification_class2	ghs_classification_class3	currency	condition_type	condition_note	product_site_launch_date	fulfillment_latency	merchant_release_date	restock_date	sale_price	sale_from_date	sale_end_date	number_of_items	offering_end_date	max_aggregate_ship_quantity	product_tax_code	offering_can_be_gift_messaged	offering_can_be_giftwrapped	is_discontinued_by_manufacturer	list_price	weee_tax_value	weee_tax_value_unit_of_measure	item_package_quantity	max_order_quantity	merchant_shipping_group_name	offering_start_date	delivery_schedule_group_id	uvp_list_price	business_price	quantity_price_type	quantity_lower_bound1	quantity_price1	quantity_lower_bound2	quantity_price2	quantity_lower_bound3	quantity_price3	quantity_lower_bound4	quantity_price4	quantity_lower_bound5	quantity_price5	national_stock_number	unspsc_code	pricing_action
the rest of my feed here|
    #'EndDate'              => $now,
    #'StartDate'            => $dt->ymd('-') . 'T' . $dt->hms(':'),
};



my $uri = URI->new($cfg->{endpoint});

$uri->path("/");
$uri->query_form($xml_vals);

my $request = HTTP::Request->new;
$request->uri($uri);

$request->content_type('application/x-www-form-urlencoded');

sign_request($request);

my $ua      = LWP::UserAgent->new();
my $response = $ua->post( $cfg->{endpoint}, $xml_vals );
my $content = $response->as_string();

print $IN->header;
use Data::Dumper;
print Dumper($content);

This runs, but the output I get is:

<?xml version="1.0"?>
<ErrorResponse xmlns="https://mws.amazonservices.com/">
  <Error>
    <Type>Sender</Type>
    <Code>InvalidParameterValue</Code>
    <Message>Maximum request size was exceeded</Message>
  </Error>
  <RequestID>8153543c-d09c-48b5-8714-c4bf5810dc5b</RequestID>
</ErrorResponse>

I’m assuming the field its complaining about is “FeedContent” due to this just being a really long string. Its sending it as a POST so I’m a bit confused as to why its complaining? Is there a simpler way to do this? (currently I’m having to do it manually by going into each marketplace, select the file, then press “submit” and wait for it to process - I would like to just have a button I press on my website that does it all in one :))

Thanks in advance

Andy

105 views
2 replies
Tags:ASIN, Compliance, Fees, Global Trade Item Number, Images, Pricing, SKU
00
Reply
2 replies
user profile
Seller_s0q4eT0IHyb5N

Hmmm just as a test, I’m giving the MWS API PHP modules a go. I copied the sample code to submit it:

/********* Begin Comment Block *********/
$feedHandle = @fopen('/home/steampj/web/xx/amazon_template_tmp/uk.csv', 'r');
fwrite($feedHandle, $feed);
rewind($feedHandle);

//echo stream_get_contents($feedHandle);

$request = new MarketplaceWebService_Model_SubmitFeedRequest();
$request->setMerchant(MERCHANT_ID);
$request->setMarketplaceIdList($marketplaceIdArray);
$request->setFeedType('_POST_PRODUCT_DATA_');
$request->setContentMd5(base64_encode(md5(stream_get_contents($feedHandle), true)));
rewind($feedHandle);
$request->setPurgeAndReplace(false);
$request->setFeedContent($feedHandle);
//$request->setMWSAuthToken('<MWS Auth Token>'); // Optional

rewind($feedHandle);
/********* End Comment Block *********/

invokeSubmitFeed($service, $request);

I have confirmed the file contents are ok (printing out the content to make sure its reading the file). When I run the script I get:

Host: mws.amazonservices.co.uk
User-Agent: Steampunk Junkies Feed Uploader/0.01 (Language=PHP/7.0.28-0ubuntu0.16.04.1; Platform=Linux/x86_64/4.18.8-x86_64-linode117; MWSClientVersion=2016-09-21)
Transfer-Encoding: chunked
Content-Type: application/octet-stream

< HTTP/1.1 200 OK
< Server: Server
< Date: Wed, 14 Nov 2018 18:12:10 GMT
< Content-Type: text/xml
< Transfer-Encoding: chunked
< Connection: keep-alive
< x-mws-quota-max: 30.0
< x-mws-quota-remaining: 24.0
< x-mws-quota-resetsOn: 2018-11-14T18:51:00.000Z
< x-mws-response-context: xxxx
< x-mws-response-context: xxx
< x-amz-request-id: 3c08eeef-ad7e-40c2-9e60-b8c9bf3492b1
< x-mws-request-id: 3c08eeef-ad7e-40c2-9e60-b8c9bf3492b1
< x-mws-timestamp: 2018-11-14T18:12:10.451Z
< x-amz-rid: xxxx
< Vary: Accept-Encoding,X-Amzn-CDN-Cache,User-Agent
<
* Connection #0 to host mws.amazonservices.co.uk left intact
Service Response
=============================================================================
        SubmitFeedResponse
            SubmitFeedResult
                FeedSubmissionInfo
                    FeedSubmissionId
                        170235017849
                    FeedType
                        _POST_PRODUCT_DATA_
                    SubmittedDate
                        2018-11-14T18:12:10Z
                    FeedProcessingStatus
                        _SUBMITTED_
            ResponseMetadata
                RequestId
                    3c08eeef-ad7e-40c2-9e60-b8c9bf3492b1
            ResponseHeaderMetadata: RequestId: 3c08eeef-ad7e-40c2-9e60-b8c9bf3492b1, ResponseContext: qXUyfjYnV2Zi1/usDs3KNgk1e0g5ETWnco1LtAWNtf5HKtlEZoww1yaYG1AE0C3EZh7kHpnWou0=,zTqSmVUfTDmliEQdBg3+3pHCV3bu+zSLnUWBUcJD5XtUlOQRh1U0nH00hAKglnwbVPlMacklHAY=, Timestamp: 2018-11-14T18:12:10.451Z

But when I go and check if the feed was submitted to the UK marketplace, I don’t see anything (just the previous batch ids that I manually submitted earlier).

UPDATE: I’m getting a little closer. It turns out actually I think it was the POST_FLAT_FILE_INVLOADER_DATA feed type I needed:

$file_contents = stream_get_contents($feedHandle);

$request = new MarketplaceWebService_Model_SubmitFeedRequest();
$request->setMerchant(MERCHANT_ID);
$request->setMarketplaceIdList($marketplaceIdArray);
$request->setFeedType('_POST_FLAT_FILE_INVLOADER_DATA_');
$request->setContentMd5(base64_encode(md5($file_contents, true)));
$request->setFeedContent($file_contents);
rewind($feedHandle);
$request->setPurgeAndReplace(false);
$request->setFeedContent($feedHandle);

I now see this come up in the list of batches… yet it tells me I didn’t upload any rows!

Any ideas?

Thanks

Andy

00
Follow this discussion to be notified of new activity