Retrieving inserted data after POST request

Hello.

I am working with the Relativity Server REST API and I’m encountering an issue when inserting new records into the FORNECEDOR table. Specifically, I’m unable to retrieve the data of the newly inserted record, including the auto-generated ID field, which is crucial for our application.

Current behavior:

Desired behavior:

  • After a successful POST request, I need the server to return the complete record that was just inserted, including all fields and especially the auto-generated ID field.

I’ve tried the following without success:

  1. Adding “Accept: application/json” header
  2. Using custom headers like “X-Return-Created-Entity: true”
  3. Adding query parameters like “$return=true”

Could you please advise on the correct method or configuration to make the server return the inserted data, particularly the ID field, immediately after a POST request? This information is critical for our application’s workflow.

Roberto.

Hi,

Is record inserted by Relativity?
do you include auto-generated ID field as negative number?
Can you show a json request was sent to server, pls?

for keeping privacy, you can drop email to support@

Hello.
“Is record inserted by Relativity?”
yes

[root@mp ~]# curl -X POST “http://127.0.0.1:7099/rest/Escola/SCH_PATRIMONIO/fornecedor” \

-H “Content-Type: application/json”
-H “Accept: application/json”
-H “Prefer: return=representation”
-H “X-Return-Created-Entity: true”
-H “Authorization: Basic QXBwOlRUZxxx1VvJno=”
-d ‘{
“NOME_FANTASIA”: “Exemplo de Nome Fantasia”,
“CNPJ”: “00.000.000/0000-01”,
“RAZAO_SOCIAL”: “Exemplo Razão Social Ltda”
}’
-v

  • About to connect() to 127.0.0.1 port 7099 (#0)
  • Trying 127.0.0.1…
  • Connected to 127.0.0.1 port 7099 (#0)

POST /rest/Escola/SCH_PATRIMONIO/fornecedor HTTP/1.1
User-Agent: curl/7.29.0
Host: 127.0.0.1:7099
Content-Type: application/json
Accept: application/json
Prefer: return=representation
X-Return-Created-Entity: true
Authorization: Basic QXBwOlRUZxxx1VvJno=
Content-Length: 155

  • upload completely sent off: 155 out of 155 bytes
    < HTTP/1.1 200 OK
    < Content-Type: text/plain; charset=utf-8
    < WWW-Authenticate: Basic realm=“”
    < Connection: Keep-Alive
    < Access-Control-Allow-Origin: *
    < Location: /rest/PAT_FORNECEDOR
    < Content-Length: 0
    < Server: RemObjects Relativity Server
    <

Hi,

works locally (I’ve put each param to new line for better reading):

curl 
-v 
-X POST "http://localhost:7099/rest/DASamples/PCTrade/Vendors" 
-H  "accept: application/json" 
-H  "content-type: application/json" 
-d "{\"Code\": \"ZZZZZ\",\"Name\": \"YYYYYY\", \"VendorSite\": \"XXXXXX\"}" 
-H "Authorization: Basic RGF0YTpSZWxhdGl2aXR5"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1:7099...
* Connected to localhost (::1) port 7099 (#0)
> POST /rest/DASamples/PCTrade/Vendors HTTP/1.1
> Host: localhost:7099
> User-Agent: curl/7.72.0
> accept: application/json
> content-type: application/json
> Authorization: Basic RGF0YTpSZWxhdGl2aXR5
> Content-Length: 69
>
* upload completely sent off: 69 out of 69 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Server: RemObjects Relativity Server
< Access-Control-Allow-Origin: *
< Connection: Keep-Alive
< Content-Length: 64
< Location: /rest/Vendors/57
< WWW-Authenticate: Basic realm=""
<
{"Id":"57","Code":"ZZZZZ","Name":"YYYYYY","VendorSite":"XXXXXX"}
* Connection #0 to host localhost left intact

try to launch above cmdline locally. will it work ?

Hello.

Following up on our previous conversation about inserting records via the REST API, I’ve tried the suggested modifications, but I’m still unable to retrieve the ID of the newly inserted record. Here’s the curl command I’m using and its output:

[Output]

accept: application/json
content-type: application/json
Authorization: Basic QXBwXXXU5a1VvJno=
Content-Length: 120

  • upload completely sent off: 120 out of 120 bytes
    < HTTP/1.1 200 OK
    < Content-Type: text/plain; charset=utf-8
    < WWW-Authenticate: Basic realm=“”
    < Connection: Keep-Alive
    < Access-Control-Allow-Origin: *
    < Location: /rest/FORNECEDOR
    < Content-Length: 0
    < Server: RemObjects Relativity Server
    <

I have some questions regarding this response:

  1. Why is the response body empty (Content-Length: 0), unlike the example you provided earlier?

  2. How can I configure the server to return the ID and details of the inserted record in the POST response?

  3. Is there any specific server configuration that needs to be adjusted to make the behavior similar to your example?

  4. The “Location” header in the response doesn’t include the specific ID of the inserted record. Is this expected behavior, or should it include the ID?

  5. Are there any specific settings for the “fornecedor” table that might be affecting the REST API behavior?

  6. Can you provide guidance on how to retrieve the ID of the newly inserted record in this scenario?

I’ve confirmed that the ID field in our Firebird database is set up as “GENERATED BY DEFAULT AS IDENTITY”. Is there any additional configuration needed on the Relativity Server side to handle this type of auto-increment field correctly?

Thank you for your assistance in resolving this issue.

Hi,

If I don’t specify Generator Name in Schema Modeler, I have

>curl -v -X POST "http://localhost:7099/rest/Employee/Schema1/CUSTOMER" -H  "accept: application/json" -H  "content-type: application/json" -d "{ \"CUSTOMER\": \"ZZZZZ1111\"}" -H "Authorization:
 Basic RGF0YTpSZWxhdGl2aXR5"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1:7099...
* Connected to localhost (::1) port 7099 (#0)
> POST /rest/Employee/Schema1/CUSTOMER HTTP/1.1
> Host: localhost:7099
> User-Agent: curl/7.72.0
> accept: application/json
> content-type: application/json
> Authorization: Basic RGF0YTpSZWxhdGl2aXR5
> Content-Length: 29
>
* upload completely sent off: 29 out of 29 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 500 InternalServerError
< Content-Type: text/plain; charset=utf-8
< Server: RemObjects Relativity Server
< Access-Control-Allow-Origin: *
< Connection: Keep-Alive
< Content-Length: 47
< WWW-Authenticate: Basic realm=""
<
Generator name for [CUSTOMER].[CUST_NO] not set
* Connection #0 to host localhost left intact

if I specify it, it works as expected:

>curl -v -X POST "http://localhost:7099/rest/Employee/Schema1/CUSTOMER" -H  "accept: application/json" -H  "content-type: application/json" -d "{ \"CUSTOMER\": \"ZZZZZ1111\"}" -H "Authorization:
 Basic RGF0YTpSZWxhdGl2aXR5"
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1:7099...
* Connected to localhost (::1) port 7099 (#0)
> POST /rest/Employee/Schema1/CUSTOMER HTTP/1.1
> Host: localhost:7099
> User-Agent: curl/7.72.0
> accept: application/json
> content-type: application/json
> Authorization: Basic RGF0YTpSZWxhdGl2aXR5
> Content-Length: 29
>
* upload completely sent off: 29 out of 29 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=utf-8
< Server: RemObjects Relativity Server
< Access-Control-Allow-Origin: *
< Connection: Keep-Alive
< Content-Length: 223
< Location: /rest/CUSTOMER/1017
< WWW-Authenticate: Basic realm=""
<
{"CUST_NO":"1017","CUSTOMER":"ZZZZZ1111","CONTACT_FIRST":null,"CONTACT_LAST":null,"PHONE_NO":null,"ADDRESS_LINE1":null,"ADDRE
SS_LINE2":null,"CITY":null,"STATE_PROVINCE":null,"COUNTRY":null,"POSTAL_CODE":null,"ON_HOLD":null}
* Connection #0 to host localhost left intact

If you connect to Relativity with usual DA client (i.e. w/o REST), will it work as expected? i.e. can it return valid value for autoinc field when you pass negative value as autoinc value?

can you prepare simple testcase with your table and steps, pls?
you can drop it to support@ for keeping privacy

Can I send you the link privately for you to test?

Hi,

sure