OData get individual property: ~/entityset/key/navigation/property - rest

I need to get an entity's individual property from OData(V4) endpoint.
It is a simple project. Models, controllers and configurations files are here
The $select is working, but it is a little different than we want. We need to get just one property(not an entity with one property) to show in a report on somewhere.
Now I'm able to get individual navigation and normal properties:
http://localhost:64659/People(Guid)/Address,
http://localhost:64659/People(Guid)/Name,
http://localhost:64659/Address(Guid)/Name
But, the following URL is not working, because we trying to get navigation property's property:
http://localhost:64659/People(Guid)/Address/Name
And the error is:
{
"error": {
"code": "",
"message": "No HTTP resource was found that matches the request URI 'http://localhost:64659/People(c6ef0e71-2107-4d58-bf0d-12d38f25045a)/Address/Name'.",
"innererror": {
"message": "No routing convention was found to select an action for the OData path with template '~/entityset/key/navigation/property'.",
"type": "",
"stacktrace": ""
}
}
}
I couldn't find anything to get this to work, any help appreciated.

Came across the same issue and used $select
http://localhost:64659/Address(Guid)?$select=Name

Related

Getting "Unsupported sort property 'deletedDateTime' for 'Group'" error

I am trying to get the list of deleted Azure AD groups via Graph API by using below query:
GET
https://graph.microsoft.com/v1.0/directory/deletedItems/microsoft.graph.group?$count=true&$orderBy=deletedDateTime+asc&$select=id,DisplayName,deletedDateTime
But I got the error like below:
{ "error": { "code": "Request_UnsupportedQuery", "message":
"Unsupported sort property 'deletedDateTime' for 'Group'.",
"innerError": { "date": "2022-05-20T10:30:41", "request-id":
"2884a7a0-ee08-4484-b63a-d927310c1dde", "client-request-id":
"0ec6c500-e899-65bf-acd8-dbd786c59773" } } }
Can anyone help me with this error? I have all the required permissions,not understanding what's going wrong.
The error usually occurs if you missed adding required header while executing the query.
I tried to reproduce the same in my environment without adding the header and got below error:
To resolve the error, make sure to add header as ConsistencyLevel: eventual like below:
After adding the header got the results successfully like below:
Reference:
List deletedItems (directory objects) - Microsoft Graph v1.0 | Microsoft Docs

Unable to modify existing properties of groups from Graph API

I am trying to modify the existing Azure Ad group display name and description from Microsoft Graph API.
I am using the query below:
PUT
https://graph.microsoft.com/v1.0/groups/mygroupobjectid
Body
{
"displayName": "Test_Group1",
"description": "This is my test group",
"groupTypes": [
"Unified"
],
"mailEnabled": true
}
But I am getting the response like below:
{
"error": {
"code": "Request_BadRequest",
"message": "Specified HTTP method is not allowed for the request target.",
"innerError": {
"date": "2022-06-15T10:32:53",
"request-id": "253a0a13-f721-4798-911f-d3ab3903da17",
"client-request-id": "8de28bb9-bafe-d186-264d-db614b05a67f"
}
}
}
Can anyone suggest what I am doing wrong? Any help will be appreciated
Please note that, you need to use PATCH method to update properties of existing Azure AD groups via Microsoft Graph API as stated in this MsDoc.
I tried to reproduce the same in my environment like below:
Before updating, my group has properties like this:
To update those properties, I ran query like below:
After executing the above query, properties are updated successfully like below:

What is the expected request to get GoToWebinar webinar details based on organiser_key?

I am trying to fetch GoToWebinar details via the
Get Webinars method
​/organizers​/{organizerKey}​/webinars
listed on the GoToWebinar API reference.
I'm passing the below body:
{
"fromTime":"2015-07-13T10:00:00Z",
"toTime":"2015-07-13T22:00:00Z"
}
But in response, I get the below error:
{
"errorId": "26a9b9a8-3a92-45b0-acdd-7ac3c3f485ac",
"requestId": null,
"timeStamp": 1587960550357,
"reason": "invalid.data",
"errorCode": "invalid.data",
**"description": "Required DateTime parameter 'fromTime' is not present",**
"incident": "5801952841989547523",
"details": null
}
The API reference guide does not specify any request structure, just mentions what is needed to be sent, and I have built my logic on the same. Yet I am unable to get a proper response.
Can anybody help me in understanding what the expected request should be?
Since this is a GET HTTP call you can not add these parameters to the Body. I mean you can but it won't be sent along with the call (only with POST/PUT). So you should add the two fields you provided to the Query Parameters instead.

Google Fit REST API "Unable to fetch DataSource for Dataset: xyz"

I'm testing out a few things in the OAuth 2.0 Playground and trying to get data in and out of Google Fit using their REST API
I have done this previously with success, I just didn't write down what I did.. now I've come back to make it a proper thing and can't get it working again.
I have access to Google Fit datasources via the dashboard. I can get a list of the dataSources that exist from:
https://www.googleapis.com/fitness/v1/users/me/dataSources
And that is successful. I have also created my own stream which has a single floating point weight value on it called
raw:com.google.weight:b6ac18c0:dten.sync
It already has data in it, I put it there last time I used it. I can select all that data by requesting a GET on the following
https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/0-1432193482000000000
It returns me all the data points I entered last time as JSON
I then try to PATCH the data adding my own data to the folliwng URL
https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/1432193482000000000-1432193482000000000
With this as a the request body
{
"minStartTimeNs": "1421912895000000000",
"maxEndTimeNs": "1432193482000000000",
"dataSourceId": "raw:com.google.weight:b6ac18c0:dten.sync",
"point": [
{
"startTimeNanos": "1421912895000000000",
"modifiedTimeMillis": "1421912895000",
"endTimeNanos": "1421912895000000000",
"value": [
{
"fPVal": 89.1
}
],
"dataTypeName": "com.google.weight"
}
]
}
But I get back
{
"error": {
"code": 400,
"message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync",
"errors": [
{
"domain": "global",
"message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync",
"reason": "invalidArgument"
}
]
}
}
I can't find any one referencing a similar anywhere soo I'm here
Also note if I miss spell my source it tells me off because they don't match the URL, if i include an empty list of data points I get the same error. I'm quite lost so I'm throwing it out there to see if anyone knows what that means
Thanks in advance
edit: i tried changing the hex code for my project's integer code and got an error about untrusted source. so i tried making a new test data source which works as expected. Slightly annoyed but guess I'll just start over..
OK I was stupid and didn't set up my own credentials in the OAuth settings in top right of the dashboard as it said to here. I forgot that bit -_- now I can access my own stream again and it shows my integer project id in the stream id not the hex one
https://developers.google.com/fit/rest/v1/get-started
Now I get invalid argument, but.. whatever >_<
edit 2:
invalid argument was because I have fPVal instead of fpVal and modifiedTimeMillis mills is not supposed to be submitted, obviously

HTTP service API error message best practise

For a error case when calling some HTTP Rest service API, the response is as follows:
{
"statusCode": "400",
"error": "Bad Request",
"message": "Can not construct instance of java.math.BigDecimal from String value 'a': not a valid representation\n at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1#2f650e17; line: 1, column: 2] (through reference chain: com.foo.services.dto.request.ItemToUpdate[\"quantity\"])",
"validation": {
"source": "PAYLOAD",
"keys": ["key"]
},
"errorIdentifiers": [],
}
I am wondering if the message field in the response is appropriate. It does reveal certain level of implementation to the end user. Is this considered as
no particular problem at all
just a bad cosmetic issue that won't cause serious problem, just not readable to end user
potential security risk that definitely needs to be fixed
I think that you should only log the stacktrace on the server side. IMO it's technical hints (in addition, perhaps the end user even doesn't use Java to interact with your API) and the only thing that interests the end user of your API is that there is here a validation error within the provided data.
Another remark is that you use the status code and statusmessage within your response payload. I think that you don't need to duplicate this since it's already present in the response.
I would suggest an error message like that:
{
"messages": {
"quantity": "this must be a valid number"
}
}
I use a JSON structure for the field messages since there could be several validation errors within the provided data. Note that it's only a suggestion and you could extend this to your exact needs.
Hope it helps.
Thierry