0

我们正在尝试使用 Graphileon 代理功能,但每次我们都会收到以下错误:

{"request":{"url":"http://127.0.0.1:8080/score/api","method":"POST","body":{"state":"*","bucket":[{"name":"Ram","tr1":"TR1","TC1":1}]}},"error":{"message":"Request `body` must be string or plain object(when `json`: true)","code":400},"code":400} with Status code 400

这是我们正在使用的代码:

var schemaUrl =  "http://localhost:8080/score/api";
var body = JSON.stringify({
                    url: schemaUrl,
                    method: 'POST',
                    body: {
                            state : "*",
                            bucket:
                            [
                                {name: "Ram", tr1: "TR1", TC1: 1}
                            ]
                        }
                });
                
console.log("body == " + body);

$.ajax({
 url: "/proxy",  
          method: "POST",
          data: body
})

你能帮忙看看缺少什么吗?

4

1 回答 1

1

body也必须是 JSON,因此您需要执行以下操作:

var body = JSON.stringify({
                    url: schemaUrl,
                    method: 'POST',
                    body: JSON.stringify({
                            state : "*",
                            bucket:
                            [
                                {name: "Ram", tr1: "TR1", TC1: 1}
                            ]
                        })
                });
于 2021-09-20T11:13:03.530 回答