1

I am trying to model the following REST call in MDriven

jQuery.ajax({
type: 'POST',
url: 'http://server.net/api/server/search.php',
data: {
'apikey': xxxxxx,
'apiversion': '3',
'action': "search",
'type':'near',
'lat':'59.91673',
'long': '10.74782',
'distance': '2000',
'limit': '10'
},
success: printJsonResponse,
dataType: 'json'
});

The ViewModel would as I understand it be as follows:

enter image description here

But it is hard to test if this is the "same" (and it doesn't work)

1 Answers1

0

One way to see what is actually sent is to send your data to some echo service that just returns what it gets.

I think there must be REST services for this. I googled "Rest echo service" and got this for example: https://postman-echo.com/get?foo1=bar1&foo2=bar2

Try to send your request to https://postman-echo.com and then write out the result.

Hans Karlsen
  • 2,275
  • 1
  • 15
  • 15
  • Ok, thanks. I guess this could work (but not as convenient as vSoapDebug). I do still have some issues: What EXACTLY does the selfVM.RestGet call do? Does anyone know? (does it add the "get?") or what/more? Using the https://postman-echo.com in the VM above only results in the HTML page response. What should I add to post the request as a REST? – Henrik Leijonhufvud Apr 18 '18 at 10:30
  • In the http protocol we have 2 important verbs - get and post. REST can use both of these. In MDriven RestGet and RestPost corresponds to these. The main difference between Get and Post is that Get can only send data via headers and params - and Post can send data via headers and params and via the message body. First we must understand what the exposed service expects. Post or Get? Then how does it expect data? – Hans Karlsen Apr 18 '18 at 10:56
  • Thanks, this is helpful when doing REST calls in MDriven – Henrik Leijonhufvud Apr 19 '18 at 19:20