Fantastic! This is perfect, thank you so much!

From your example, at a minimum I had to add two parameters to my ajax:

contentType: "application/json",
dataType: "json",

And then to retrieve them, the REST service simply needs this to send back to the client whatever was in the message:

set jsonstring = $ZCONVERT(%request.Content.Read(),"I","UTF8")
set data = {}.%FromJSON(jsonstring)
write data.%ToJSON()

Thanks again!

David

Yes, this is the whole call, with the intention of receiving whatever I sent back to me:

$.ajax({
                headers: { "Authorization": "Basic " + btoa("username:password") },
                url:"serverurl/returnresponse",
                type: "POST",
                data: {
                    "payload": "some data"
                },
                success: function (response) {
                    console.log(response);
                }

});

 

Then the route:

<Route Url="/returnresponse" Method="POST" Call="ReturnResponse" Cors="false"/>
 

The method:

ClassMethod ReturnResponse() as %Status {
    try {
        set obj = %request.Data //...Contents...etc.
        write obj   
    }
    catch ex {
        write ex.Name
    }
    return $$$OK
}

Hello,

From what you've provided, this looks like a javascript error simply indicating that the function it's looking for doesn't exist. How are you calling cspHttpServerMethod? In the section Calling Server-side Methods Using #server on this documentation chapter, the proper javascript syntax is given to call server-side methods.

For example from the doc,

function test(value)
{
   // invoke server-side method Test
   #server(MyPackage.Test(value))#;
}