POST 405 (Method Not Allowed)

只谈情不闲聊 提交于 2020-01-07 09:01:27

问题


I am trying to build a Chrome Extension that uses the BOX api.

I am able to authentificate and enable access for the app, and then I extract and store the access token from the URL.

The next step would be to upload a file to box, and I am trying to use the code they provided on the website with small modifications:

//file - a csv file I created before

var uploadUrl = 'https://upload.box.com/api/2.0/files/General';

// The Box OAuth 2 Header. Add your access token.
var headers = {
    Authorization: 'Bearer '+localStorage.authorization_token
};

$.ajax({
    url: uploadUrl,
    headers: headers,
    type: 'POST',
    // This prevents JQuery from trying to append the form as a querystring
    processData: false,
    contentType: false,
    data: link
}).complete(function ( data ) {
    // Log the JSON response to prove this worked
    console.log(data.responseText);
});

But upon running the code it gives me the following error:

405 (Method Not Allowed)

POST https://upload.box.com/api/2.0/files/General 405 (Method Not Allowed)k.cors.a.crossDomain.send @ jquery.js:4n.extend.ajax @ jquery.js:4downloadCSV @ content.js:351(anonymous function) @ content.js:276 content.js:361

NOTE: I contacted api@box.com and they said they enabled CORS for my account

In my manifest.json I have "permissions": ["tabs", "<all_urls>","storage" , "alarms" ]

来源:https://stackoverflow.com/questions/33733277/post-405-method-not-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!