HISE Logo Forum
    • Categories
    • Register
    • Login

    problems with Server API - callWithPOST

    Scheduled Pinned Locked Moved General Questions
    3 Posts 2 Posters 165 Views
    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.
    • LindonL
      Lindon
      last edited by

      So I have a server set up that expects a JSON parameter that looks like this:

      const var p =
              {
                  "email:": "user1@testing.com",
                  "password:": "password"
              };
      

      and everything works fine in postman when I set the pram "type" to JSON

      9740f6eb-cc77-4bc9-8f59-f0d20b85268a-image.png

      BUT....

      when I pass this same structure using Server.callWithPost:

       const var p =
              {
                  "email:": "user1@testing.com",
                  "password:": "password"
              };
              
              Server.callWithPOST("/api/user/login/1", p, function(status, response)
              {
                  Console.print("status is:" + status);
                  Console.print("response is:" + trace(response));
      

      I get this back:

      Interface: status is:400
      Interface: response is:[
        {
          "msg": "Invalid value",
          "param": "email",
          "location": "body"
        }
      ]
      

      Interestingly when I change the parameter "type" to text in Postman I get the same response...

      0581beff-c75b-401d-8048-8190faa02962-image.png

      So..... one possible conclusion here is that the Server.callWithPOST isnt sending JSON , its sending text - but this flies in the face of my understanding of what POST does (simply inserts the params "on the fly" as text) but that could be very very wrong of me.

      Any one have any ideas?

      HISE Development for hire.
      www.channelrobot.com

      LindonL 1 Reply Last reply Reply Quote 0
      • LindonL
        Lindon @Lindon
        last edited by

        @Lindon said in problems with Server API - callWithPOST:

        const var p =
        {
        "email:": "user1@testing.com",
        "password:": "password"
        };

        ...and one of us is a duffer - and its not you....

        look at this:

        const var p =
                {
                    "email:": "user1@testing.com",
                    "password:": "password"
                };
        

        Can you spot the problem???? its this:

        "email:": "user1@testing.com
        

        really? "email:" ? really ?? whats that extra colon doing in there? - some times I go beyond embarrassing myself...

        HISE Development for hire.
        www.channelrobot.com

        ustkU 1 Reply Last reply Reply Quote 4
        • ustkU
          ustk @Lindon
          last edited by

          @Lindon The good news is that you save us from embarrassing ourselves 😛

          Can't help pressing F5 in the forum...

          1 Reply Last reply Reply Quote 1
          • First post
            Last post

          12

          Online

          1.7k

          Users

          11.8k

          Topics

          102.6k

          Posts