problems with Server API - callWithPOST



  • 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?



  • @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...



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


Log in to reply
 

10
Online

1.2k
Users

3.9k
Topics

34.4k
Posts