• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 4 Documentation Website Mango 5 Documentation Website Radix IoT LinkedIn

    HttpBuilder Error

    Scheduled Pinned Locked Moved User help
    4 Posts 2 Posters 1.3k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • 李禹廷李 Offline
      李禹廷
      last edited by

      HI All
      I 'm sorry my English is not good
      I need Help
      use Global scripts HttpBuilder my program

      print(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 7

      use cmd.exe program
      curl -X POST -H "Authorization: Bearer <my API key>" -F "message=test" https://notify-api.line.me/api/notify

      it works well
      please help me thanks

      Tim

      1 Reply Last reply Reply Quote 0
      • 李禹廷李 Offline
        李禹廷
        last edited by

        my mango v4.3.5 install to PC

        MattFoxM 1 Reply Last reply Reply Quote 0
        • MattFoxM Offline
          MattFox @李禹廷
          last edited by MattFox

          @李禹廷 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

          Do not follow where the path may lead; go instead where there is no path.
          And leave a trail - Muriel Strode

          李禹廷李 1 Reply Last reply Reply Quote 1
          • 李禹廷李 Offline
            李禹廷 @MattFox
            last edited by

            @MattFox HI
            thank you sample it works well
            Tim

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post