OData / RESTier

A turn-key library for building RESTful services
http://odata.github.io/RESTier
Other
473 stars 135 forks source link

Post operation of creating user with Trips failing #706

Open RoronoaSrinu opened 2 years ago

RoronoaSrinu commented 2 years ago

We are from Adobe System part of the AEM Forms Product team. We were trying to make use of your APIs for an internal PoC.

We are using HTTP requests : https://www.odata.org/getting-started/understand-odata-in-6-steps/

In the process we encountered some trouble. When we try to submit user details along with trip data, the POST call fails. It doesn’t accept the key ‘Trips’ in the Request body of the object.

However, when we do a GET to retrieve existing data, we are able to see the key ‘Trips’, with value populated under it.

sample request for post people/person

{
    "Person": {
        "UserName": "test159",
        "FirstName": "qui Excepteur eiusmo",
        "LastName": "ametullamco in",
        "Emails": [
            "veniam incidid",
            "deserunt dolore"
        ],
        "Gender": "Male",
        "AddressInfo": [
            {
                "Address": "cupidatat anim",
                "City": {
                    "CountryRegion": "deserunt",
                    "Name": "sint magna cup",
                    "Region": "sedex"
                }
            }
        ],
        "Trips": [
            {
                "TripId": 561,
        "Tags": [
                    "idani",
                    "anim sunt ei",
                    "consect"
                ],
                "ShareId": "Excepteur",
                "Description": "officia",
                "Name": "irure Ut ad consectet",
                "Budget": 13
            },
            {
                "TripId": 663,
        "Tags": [
                    "idani",
                    "anim sunt ei",
                    "consect"
                ],
                "ShareId": "Excepteur1",
                "Description": "officia 1",
                "Name": "irure Ut ad consectet 11",
                "Budget": 136
            }
        ]
    }
}
robertmclaws commented 2 years ago

Hello! I would need to get a little more information about what specific error message you're seeing, and also what version of Restier you are using. Then I can dig in and see what is up.

Thanks!

RoronoaSrinu commented 2 years ago

Hi @robertmclaws ,

Thanks for your response.

using https://services.odata.org/v4/(S(34wtn2c0hkuk5ekg0pjr513b))/TripPinServiceRW/People from

https://www.odata.org/getting-started/understand-odata-in-6-steps/ oData V4. Http Request

Please find sample request, response if we send request with Trips as array it fails but if we send with Trip as array it is successful but response gives Trips: null.

Failure scenario: Request for POST Person/People { "Person": { "UserName": "test1590", "FirstName": "Srinu", "LastName": "vasu", "Emails": [ "srinu@gmail.com", "TestUser@gmail.com" ], "Gender": "Male", "AddressInfo": [ { "Address": "city creek", "City": { "CountryRegion": "USA", "Name": "salt lake city", "Region": "Utah" } } ], "Trips": [ { "TripId": 561, "Tags": [ "fun", "adventure", "cycling" ], "ShareId": "SRTRR565772", "Description": "official biking trips", "Name": "Utah adventures", "Budget": 130 }, { "TripId": 663, "Tags": [ "snow", "hiking", "skating" ], "ShareId": "STYEU44783", "Description": "official snow hiking trip", "Name": "snow wonder", "Budget": 136 } ] } } Response: { "errorMessage": "Unexpected error while invoking service" } Successful scenario

Request: { "Person": { "UserName": "test1590", "FirstName": "Srinu", "LastName": "vasu", "Emails": [ "srinu@gmail.com", "TestUser@gmail.com" ], "Gender": "Male", "AddressInfo": [ { "Address": "city creek", "City": { "CountryRegion": "USA", "Name": "salt lake city", "Region": "Utah" } } ], "Trip": [ { "TripId": 561, "Tags": [ "fun", "adventure", "cycling" ], "ShareId": "SRTRR565772", "Description": "official biking trips", "Name": "Utah adventures", "Budget": 130 }, { "TripId": 663, "Tags": [ "snow", "hiking", "skating" ], "ShareId": "STYEU44783", "Description": "official snow hiking trip", "Name": "snow wonder", "Budget": 136 } ] } } Response: { "UserName": "test1590", "FirstName": "Srinu", "Friends": null, "LastName": "vasu", "Emails": [ "srinu@gmail.com", "TestUser@gmail.com" ], "Gender": "Male", "Trips": null, "AddressInfo": [ { "Address": "city creek", "City": { "CountryRegion": "USA", "Region": "Utah", "Name": "salt lake city" } } ] }

robertmclaws commented 11 months ago

Hello @RoronoaSrinu. Apologies for not getting back to you on this. Were you able to get this working? The error came from posting the wrong type of object to the endpoint. That URL was "/People, so you would have needed to post a Person in order for it to go through... however it's not likely that the Trips would have been added without a BATCH request or DELTA payload.

Thanks!