최근 검색


최근 검색 없음

rajesh parmar's Avatar

rajesh parmar

가입한 날짜: 2024년 11월 26일

·

마지막 활동: 2024년 11월 27일

팔로잉

0

팔로워

0

총 활동 수

3

투표 수

0

가입 플랜

1

활동 개요

님의 최근 활동 rajesh parmar

rajesh parmar님이 에 댓글을 입력함

커뮤니티 댓글 Developer - Zendesk SDKs

Erica Girges 
i add ‘application/binary’ as contentType but still not work 

 

댓글 보기 · 2024년 11월 27일에 게시됨 · rajesh parmar

0

팔로워

0

투표 수

0

댓글


rajesh parmar님이 에 댓글을 입력함

커뮤니티 댓글 Developer - Zendesk SDKs

Hello Tipene Hughes 

I have an issue with the POST request using client.request. Here is the code I'm working with:
 

const base64Response = await fetch(mediaData.data);
const blobData = await base64Response.blob();
const file = new File([blobData], mediaData.fileName, {
type: blobData.type,
});
const formData = new FormData();
formData.append("media", file);
formData.append("title", file.name);
formData.append("content_type", file.type);
formData.append("account", spokiAccount?.id);
const metadata = await client.metadata();
const sendMedia = await client.request({
 url: `${BASE_URL}/media/`,
 type: "POST",
 data: formData,
 headers: {
   "Content-Type": "multipart/form-data",
   [zendeskHeaderKey]: typeof metadata.installationId === "string" ? spokiAccessKey : "{{setting.spokiAccessKey}}",
 },
 secure: !(typeof metadata.installationId === "string"),
});
 

The issue is that when I make the API call using Axios, like this:
 

const sendMedia = await axios.post(`${BASE_URL}/media/`, formData, {
 headers: {
   "Content-Type": "multipart/form-data",
   ...spokiHeaders,
 },
});
 

It works fine and returns a response. However, when I call the API using the client.request, the payload doesn’t show up in the browser, and I get a 400 error with the following message:
 

{
 "media": [
   "No file was submitted."
 ]
}
 

Can you help me identify what might be wrong with the client.request approach?

댓글 보기 · 2024년 11월 26일에 편집됨 · rajesh parmar

0

팔로워

0

투표 수

0

댓글