Microsoft graph api attachment error of unable to deserialize - microsoft-graph-api

I have tried this i am able to create event but this error i am getting.
body_json={
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "menu.txt",
"contentBytes": "base64bWFjIGFuZCBjaGVlc2UgdG9kYXk="
}
API =" https://graph.microsoft.com/v1.0/users/{}/events/{}/attachments".format(userId,meetingID)
body_json = json.dumps(body_json)
response = requests.request("POST", url=API, data=body_json, headers=self.headers)
error : <Response [400]> {"error":{"code":"UnableToDeserializePostBody","message":"were unable to deserialize "}}

The issue here is because the data which you are putting in the contentBytes property is not BASE64. As you are following the documentation they gave that example to make you understand that the data is base64. But actually in the example its not base64. So you can convert it to base64 online as below and test it.
This is the request body I used which has Hello World.
{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "menu.txt",
"contentBytes": "SGVsbG8gV29ybGQ="
}
Which gave me successful results in graph explorer. You can use it to test Graph API calls.

Related

Updating IPP printer attributes using Graph API with "application/ipp" payload returns error

Microsoft have provided the Graph API for updating the printer attributes, I could send a JSON or a IPP payload, JSON payload works fine, but updating printer attributes (Group 2 as in the https://ftp.pwg.org/pub/pwg/candidates/cs-ippinfra10-20150619-5100.18.pdf) with a IPP payload returns the following error.
{
"error": {
"code": "500",
"message": "Additional data found after serialized IPP attribute group.
First byte of additional data: Reserved",
"innerError": {
"date": "2020-09-29T09:25:18",
"request-id": "e103342b-96a3-44b0-adb2-f97b29dc3846",
"client-request-id": "e103342b-96a3-44b0-adb2-f97b29dc3846"
}
}
}
what is wrong with the payload, Any idea why?
There is a similar issue reported in Github and issue has been closed, there is no resolution details.

Cumulocity SmartREST GET Template using MQTT

I am trying to receive a response using a custom GET template implemented on the Cumulocity UI however I'm having some trouble. I have defined my message template like so:Message Template and my response template like so: Response template.
At the moment when I publish to topic 's/uc/template1' (where template1 is my X-ID) with the payload of '999, 12345'(where 12345 is my External ID), no response is received and no error is found. The speeds are known to exist in the object because when I request a GET command to {{url}}/inventory/managedObjects this responds with:
"speed": {
"1": {
"unit": "m/min",
"value": 1
},
"2": {
"unit": "m/min",
"value": 1
}
I've also followed this post where #TyrManuZ suggests to add c8y_Global: {} to the application. I have done this through a PUT request to {{url}}/inventory/managedObjects/{{deviceId}} on Postman and can verify that c8y_Global: {} exists there.
Is there something I am doing wrong, and if so what is the correct way? Any help would be greatly appreciated!

groupPolicyConfigurations/{groupPolicyConfigurationId}/updateDefinitionValues can't update configuration with API

I am trying to update my Microsoft Intune Configuration using Microsoft Graph API.
For this I am using Postman. I have set up an app registration to assign the needed permissions and retrieve an access token. This is working in so far that I can read most of my configurations.
Now I am trying to change a configuration using POST /deviceManagement/groupPolicyConfigurations/{groupPolicyConfigurationId}/updateDefinitionValues. (Docs)
Now the problem is when I forming the request according to the docs:
{ "added":[],
"updated":[{
"#odata.type": "#microsoft.graph.groupPolicyDefinitionValue",
"createdDateTime": "2017-01-01T00:02:43.5775965-08:00",
"enabled": true,
"configurationType": "policy",
"id": "<id>",
"lastModifiedDateTime": "2017-01-01T00:00:35.1329464-08:00"
}],
"deletedIds":[]}
I get:
error code: BadRequest
"date": "2020-11-04T19:04:33",
"request-id": "c66c508b-0f73-4e7f-966a-97bf460818be",
I also tried to inspect the requests sent by the Azure Portal when changing the it in the UI and the Graph API request sent by the UI is quite a bit different than the one from the docs:
{ "added":[],
"updated":[{
"id":"<id>",
"enabled":true,
"presentationValues":[],
"definition#odata.bind":"https://graph.microsoft.com/beta/deviceManagement/groupPolicyDefinitions('<id>')"
}],
"deletedIds":[]}
and this one returns a HTTP 403 Forbidden I get a
error code: BadRequest
"date": "2020-11-04T19:04:27",
"request-id": "c70d67bc-b4d4-40cc-b2c9-7d60896f972a",
Unfortunately the response does not contain any information on what exactly the issue is and I don't know if there is any logs where I could find a more detailed error description.
Does anybody have experience with this and knows where I could get the correct payload for the request?

Unable to get teams message attachment content using graph API

I am able to get message attachment information as shown below but unable to download the file content which is stored in share point site.
"attachments": [
{
"id": "fc323b65-2cee-48d9-9574-0e26eb74e9bb",
"contentType": "reference",
"contentUrl": "https://otdeveloper.sharepoint.com/sites/Test/Shared Documents/General/1Ex.txt",
"content": null,
"name": "1Ex.txt",
"thumbnailUrl": null
}
]
I am using the following get call for the above request with auth token
GET https://graph.microsoft.com/beta/groups/{{TeamId}}/drive/root:/Test/Shared Documents/General/1Ex.txt:/content
I tried the solution posted in
https://github.com/microsoftgraph/msgraph-sdk-javascript/issues/200
but I am getting 404 response.
Could you please check Get message API.You will receive the the attachments info in the response as shown below

A post call to add a new openTypeExtension to event data fails with “Resource not found for the segment 'extensions'”

I am trying to add an extension to the event resource using Graph Explorer. I am using POST on https://graph.microsoft.com/v1.0/event/extensions with request body
{
"#odata.type": "microsoft.graph.openTypeExtension",
"extensionName": "com.wrike.WrikeIDs",
"id": "",
"permalink": ""
}
I get the error
"Resource not found for the segment 'event'"
and sometimes I get
"The OData request is not supported"
Content type is application/json
The error message might be misleading.
Try to adjust the path to
POST https://graph.microsoft.com/v1.0/me/events/{event_id}/extensions

Resources