#1 2017-11-17 13:39:19

factor200x
Member
Registered: 2017-05-23
Posts: 15

POST Record to REST, how do I get the ID?

Hello,

I have another problem and hope that someone can give me a clue. 

I send a new record to the REST server from the browser via Ext.Ajax.request. The dataset is created and I get a response message that the dataset is being created. The response also contains the data I sent. What I miss is the record ID that was assigned when the record was created.

I hope I was able to explain the problem reasonably by then!?

How do I get the REST server to send me the ID of the created record back without having to set an interface function?

I would like to thank you in advance
Olaf

Offline

#2 2017-11-17 13:56:01

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 336

Re: POST Record to REST, how do I get the ID?

Check the headers in the HTTP response, the new record ID is there.


Esteban

Offline

#3 2017-11-17 16:06:48

factor200x
Member
Registered: 2017-05-23
Posts: 15

Re: POST Record to REST, how do I get the ID?

Hello Esteban,

unfortunately not.

Chrome time the following:

General:

Request URL:http://b6996c001.4all-media.root:8990/V1/MAS/Title/
Request Method:POST
Status Code:201 Created
Remote Address:169.254.63.187:8990
Referrer Policy:no-referrer-when-downgrade
Response Header 

HTTP/1.1 201 Created
Location: Title/23
Server: mORMot (Windows) Microsoft-HTTPAPI/2.0
X-Powered-By: mORMot 1.18 synopse.info
Server-InternalState: 28
Access-Control-Allow-Methods: POST, PUT, GET, DELETE, LOCK, OPTIONS
Access-Control-Max-Age: 1728000
Access-Control-Expose-Headers: content-length,location,server-internalstate
Access-Control-Allow-Origin: *
Accept-Encoding: synlz,gzip
Date: Fri, 17 Nov 2017 15:55:18 GMT
Content-Length: 0
Requerst Header

POST /V1/MAS/Title/ HTTP/1.1
Host: b6996c001.4all-media.root:8990
Connection: keep-alive
Content-Length: 33
Pragma: no-cache
Cache-Control: no-cache
Origin: http://b6996c001.4all-media.root:1841
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
Content-Type: application/json
Accept: */*
DNT: 1
Referer: http://b6996c001.4all-media.root:1841/?locale=de/
Accept-Encoding: gzip, deflate
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
Request Payload

{"Name":"Test 3","Active":"true"}

I don't understand. The search continues...; -)

But despite everything, thank you very much!

Olaf

Offline

#4 2017-11-17 16:13:14

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 336

Re: POST Record to REST, how do I get the ID?

In "Location: Title/23" it's the answer: "23" is the new ID in table "Title".


Esteban

Offline

#5 2017-11-17 16:23:15

factor200x
Member
Registered: 2017-05-23
Posts: 15

Re: POST Record to REST, how do I get the ID?

Hello, me again,

I found it. The following parameter must be set.

Great and thank you very much
Olaf

DB.Options := [rsoAddUpdateReturnsContent];

Offline

Board footer

Powered by FluxBB