HttpBuilder Error
-
HI All
I 'm sorry my English is not good
I need Help
use Global scripts HttpBuilder my programprint(HttpBuilder.request({ path: "https://notify-api.line.me/api/notify", method: "POST", headers: { "Authorization":"Bearer <my API key>", "ContentType":"application/x-www-form-urlencoded", "Accept": "application/json" }, form:{ "message":"test" }, err: function(status, headers, content) { throw "Request got bad response: "+ status; }, resp: function(status, headers, content) { print(content); return true; }, excp: function(exception) { throw exception.getMessage(); } }))
Error code:
javax.script.ScriptException: Request got bad response: 400 in <eval> at line number 18 at column number 7use cmd.exe program
curl -X POST -H "Authorization: Bearer <my API key>" -F "message=test" https://notify-api.line.me/api/notifyit works well
please help me thanksTim
-
my mango v4.3.5 install to PC
-
@李禹廷 Welcome
If you're using POST with a form-url-encoded system, you should be sending them inside a content object, not form. Secondly, you've miss-typed your headers:HttpBuilder.request({ path: URL, method: "POST", headers: { "Content-Type":"application/x-www-form-urlencoded", "Accept": "application/json, text/plain, */*" }, content: "message=test", err: function(status, headers, content) { //errorCallback for linguistic completion throw "Request got bad response: " + status; }, resp: function(status, headers, content) { //responseCallback print(content); return true; //will print in wrapping print() }, excp: function(exception) { //exceptionCallback throw exception.getMessage(); }});
This should get you started
Fox
-
@MattFox HI
thank you sample it works well
Tim