Upload new version in file - Getting "Unsupported Media Type"

新規投稿

コメント

3件のコメント

  • jcleblanc

    Hi ,

     

    Could you try changing the content-type to "application/json", since you're uploading a JSON file, and see if that solves the problem please?

     

    If that doesn't work can you supply your code please? The 400 error is telling me that there's an issue with the request coming through. 

     

    Thanks,

    Jon

    0
    コメントアクション パーマリンク
  • swathi_0812

    Hi  ,

     

    Thanks. I have tried using the content-type as "application/json" but 415 error persists. PFB the code i have tried,

     

     

    let filePath = "../../folder1/fileName.json";
        var form = new FormData();
        form.append("attributes", "{name:fileName.json}");
        form.append("file", filePath);
    
        return axios({
            method: 'POST',
            url: `https://upload.box.com/api/2.0/files/${FILE_ID}/content`,
            data: form,
            headers: {
                'Authorization': 'Bearer ' + access_token,
                'content-type': 'multipart/form-data; boundary=---- 
                                 WebKitFormBoundary7MA4YWxkTrZu0gW', // Response : 400 - API upload didnot have a file part
                // 'content-type': 'application/json', -> Response : 415 - unsupported media type
                // 'content-type': 'application/x-www-form-urlencoded', -> 415 - unsupported media type
            },
        }).then(function (response) {
            console.log("response", response)
            return response.data;
        }).catch((error) => {
            console.log('error', error);
        });

     

     

    0
    コメントアクション パーマリンク
  • swathi_0812

    Can anyone please suggest solution for this issue ?

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。