Web HTTP请求在Java和请求(python)中工作,但在axios中不工作
我想向布谷鸟沙盒的API发送一个URL以进行处理: 在他们的官方文档中,他们给了我一个python代码:Web HTTP请求在Java和请求(python)中工作,但在axios中不工作,web,python-requests,axios,insomnia,cuckoo,Web,Python Requests,Axios,Insomnia,Cuckoo,我想向布谷鸟沙盒的API发送一个URL以进行处理: 在他们的官方文档中,他们给了我一个python代码: import requests REST_URL = "http://localhost:8090/tasks/create/url" SAMPLE_URL = "url/path" HEADERS = {"Authorization": "Bearer S4MPL3"} data = {"url&qu
import requests
REST_URL = "http://localhost:8090/tasks/create/url"
SAMPLE_URL = "url/path"
HEADERS = {"Authorization": "Bearer S4MPL3"}
data = {"url": SAMPLE_URL}
r = requests.post(REST_URL, headers=HEADERS, data=data)
task_id = r.json()["task_id"]
此代码有效
然后我尝试使用axios在noedJS中实现代码,因此我从do it n开始,它可以工作:
正如您所看到的,它也可以工作:
但当我尝试通过axios执行此操作时,响应不是错误
但是它返回我{task\u id:null}
代码如下:
let config = {
headers: {
Authorization: "Bearer kbOX2efe5Agq1LoTMJCy8w",
'Content-Type' :"multipart/form-data"
},
data: {"url" :"https://cuckoo.readthedocs.io/en/latest/usage/api/"}
}
axios.post("http://localhost:8070/tasks/create/url", config) .then(response => { res.send(response.data) }) .catch((error) => { res.send(error.response) })