Forum

    • Register
    • Login
    • Search
    • Categories

    problems with Server API - callWithPOST

    General Questions
    2
    3
    81
    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.
    • Lindon
      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

      Lindon 1 Reply Last reply Reply Quote 0
      • Lindon
        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

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

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

          I can't help pressing F5 in the forum...

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

          4
          Online

          1.1k
          Users

          7.0k
          Topics

          64.7k
          Posts