Hi, I am a new developer so there is most probably a fault on my side.
All my other requests work perfectly, i.e. get (all), post, put and delete.
Hoverwer whenever I request http get(id) an undefined object is returned.
Please let me know what you need to figure out what's happening.
enchev
November 6, 2019, 1:57pm
2
Can you post the response of this request from browser network tab?
${result} when calling get(id) request with radzen
Result when calling get(id) via postman:
{
"id": 1,
"code": "string",
"title": "string",
"initials": "string",
"firstName": "string",
"lastName": "string",
"gender": "string",
"birthDate": "2019-11-06T00:00:00",
"maritalStatus": "string",
"idType": "string",
"idNumber": "string",
"isDeleted": true,
"clientIds": [],
"clientRelatedIds": [],
"leadIds": [],
"addressIds": [],
"bankAccountIds": [],
"contactIds": [],
"occupationIds": []
}
Hope this helps
I think u missunderstood,
this is what was in the network tab when making the request with radzen
enchev
November 6, 2019, 5:18pm
5
According to the result an object is properly returned. What is undefined?
this is what I get when I log $(result) after doing the request
enchev
November 7, 2019, 6:20am
7
This is different from the previous screenshot from your browser console. Where you log the result? Can you post a screenshot?
enchev
November 7, 2019, 8:03am
9
Can you post also what parameters are passed for this Invoke?
I have just used 1 for now to test, as I definitely know there is a person with id 1 in my database. I will be using page parameters in my actual application.
enchev
November 7, 2019, 9:03am
11
Everything looks correct. In this post the response is correct: Http GetByID returning undefined object . How you've executed the request? Is it from the same invoke?
I looked around in the generated files and found the problem in the generated .services file.
Is there something I could've done incorrectly on my side to cause the services being generated like this?
enchev
November 7, 2019, 10:55am
14
Here is the Swagger generated by Radzen for getBy when accessing SQL database:
],
"responses": {
"204": {},
"default": {
"schema": {
"$ref": "#/definitions/Error"
}
}
}
},
"get": {
"operationId": "getContactById",
"parameters": [
{
"in": "path",
"name": "Id",
"type": "integer"
}
],
"responses": {
"200": {
What’s the difference compared to your Swagger?
"/api/persons/{id}": {
"get": {
"tags": [
"Persons"
],
"operationId": "GetPersonAsync",
"consumes": [],
"produces": [],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "integer",
"format": "int32"
}
],
"responses": {
"200": {
"description": "Success"
}
}
},
Here is the code in my Data.json file. I have no idea what to look for.
korchev
November 7, 2019, 11:23am
16
Your Swagger is not valid as the response does not specify any schema - only description.
Thanks, I will try and see how I can fix it on my side. Thank you for helping, sorry for any inconvenience.
korchev
November 7, 2019, 12:20pm
18
I should correct my answer a bit. Your swagger is valid however it does not correctly represent your REST API which returns a response.