-
I am coming up with an error for running the following code Feeds().create_feed_document(file = "myfile.txt", content_type = "text/plain; charset=utf-8") This is the error im getting which is believe is in reference to feed.py line 172 in create_feed_document, upload_data = file.read() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Bro, the content_type is to specify which type of document you are uploading, is not a part of the api …. If you are using txt you need “text/plain”, if you use xml you need use "application/xml”,…etc
You can see a list of the possible values here:
https://www.geeksforgeeks.org/http-headers-content-type/
"
… El 30 dic 2022, a las 2:07, esbezr ***@***.***> escribió:
I am trying to submit a create feed document but i cant find what values i need to put in the "content_type". I know it needs to be a string but where can i find the options for what to put in there. My code is below.
Feeds().create_feed_document(file = "myfile.txt", content_type = str)
I found in some of the documentation a string that says "text/tab-separated-values; charset=UTF-8" but i cant find any others.
—
Reply to this email directly, view it on GitHub <#864>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AD4ENUVX42JBNSQJLBOJSG3WPXHNPANCNFSM6AAAAAATMJHA5A>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
-
Solution: import os feed = BytesIO() res = Feeds(marketplace = Marketplaces.US).create_feed_document(file = feed, content_type = "text/html; charset=utf-8") |
Beta Was this translation helpful? Give feedback.
Solution:
import os
from sp_api.api import Feeds
from sp_api.base import Marketplaces
from io import BytesIO
import sys
feed = BytesIO()
file = str.encode("myfile.txt")
feed.write(file)
feed.seek(0)
res = Feeds(marketplace = Marketplaces.US).create_feed_document(file = feed, content_type = "text/html; charset=utf-8")
FDI = res.payload['feedDocumentId']
cre = Feeds(marketplace = Marketplaces.US).create_feed('POST_FLAT_FILE_INVLOADER_DATA', FDI)