Server API Connect PUT based on GET values


#1

I have successfully connected the Server API to a datasource and can query all records and list them in a repeat.

I authenticate server side and call a URL
e.g. http://my.webservice/test/{123456789}/accountlist

This then lists all customers and the response contains the name, limit etc.

"$resources": [
    {
      "$url": "http://my.webservice/test/{123456789}/accountrecord(1dfc-4dba-8cac)",
      "$uid": "1dfc-4dba-8cac",
      "active": true,
      "name": "ABC Ltd",
      "credit": "1000",
}]

I need to perform a PUT method to update the desired selected record.

The URL to post to is the $url value in the response or it’s always http://my.webservice/test/{123456789}/accountrecord with $uid enclosed in brackets.

Any pointers would be really appreciated.

Thanks


#2

Am I missing something here?
If I set up a PUT Server Action to http://my.webservice/test/{123456789}/accountrecord
and surround the $uid with () in a variable can I add the (1dfc-4dba-8cac) to the URL path?

Thanks in advance

Mim


#3

For PUT actions indeed use method PUT on the API action.

For using expressions make sure those are server connect expressions enclosed in {{…}}


#4

Sorry to be a pain…
I GET all the records using an Authenticated URL
http://my.webservice/test/{123456789}/accountlist
In a repeat these are listed on my page and working fine.

I then have an dmx-on:click that sets a couple of variables to the selected records $uid surrounded in brackets dmx-bind:value="'('+varuid.value+')'" and the $url which is the endpoint for that records update. http://my.webservice/test/{123456789}/accountrecord(1dfc-4dba-8cac)
I have a form with an input to set the credit value.

I need to send a PUT to the endpoint returned in the query/repeat
http://my.webservice/test/{123456789}/accountrecord($uid)
or $url

But I am not sure how I can set the Server API connect path to the dynamic value?

Many thanks

Mim


#5

Hi @George
Are you saying that if is enclose the $uid variable in {{...}} I should be able to append this to the Server API Connect URL?


#6

Hi guys,
I’m still struggling to traverse from a Server API Connect $url Response to perform the PUT
Are there any guidelines?

Thanks