Intune azure graph api to Create deviceCompliancePolicyState Returns 400 Bad Request - api

Call
GET https://graph.microsoft.com/beta/managedDevices/dd9615c4-9d3b-4ece-9272-34a10e8fe908/
RESPONSE
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#managedDevices/$entity",
"id": "dd9615c4-9d3b-4ece-9272-34a10e8fe908",
"userId": null,
"deviceName": "iPad Feb23",
"hardwareInformation": {
"serialNumber": null,
"totalStorageSpace": 0,
"freeStorageSpace": 0,
"imei": "",
"meid": null,
"manufacturer": null,
"model": null,
"phoneNumber": null,
"subscriberCarrier": null,
"cellularTechnology": null,
"wifiMac": null,
"operatingSystemLanguage": null,
"isSupervised": false,
"isEncrypted": false,
"isSharedDevice": false,
"sharedDeviceCachedUsers": []
},
"ownerType": "personal",
"deviceActionResults": [],
"managementState": "managed",
"enrolledDateTime": "2017-05-24T13:10:20.8964572Z",
"lastSyncDateTime": "2017-05-24T15:16:02.6465376Z",
"chassisType": "tablet",
"operatingSystem": "iOS",
"deviceType": "iPad",
"complianceState": "compliant",
"jailBroken": "False",
"managementAgents": 2,
"managementAgent": "mdm",
"osVersion": "9.3.5",
"easActivated": false,
"easDeviceId": null,
"easActivationDateTime": "0001-01-01T00:00:00Z",
"aadRegistered": null,
"enrollmentType": "userEnrollmentWithServiceAccount",
"lostModeState": "disabled",
"activationLockBypassCode": null,
"emailAddress": null,
"azureActiveDirectoryDeviceId": "00000000-0000-0000-0000-000000000000",
"deviceRegistrationState": "registered",
"deviceCategoryDisplayName": null,
"isSupervised": false,
"exchangeLastSuccessfulSyncDateTime": "0001-01-01T00:00:00Z",
"exchangeAccessState": "none",
"exchangeAccessStateReason": "none",
"remoteAssistanceSessionUrl": "",
"isEncrypted": false,
"model": null,
"manufacturer": null
}
But when i try to do post nothing seems to work ... according to the doc here https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/intune_mam_mobileappidentifierdeployment_create
it should work just fine what is the problem with this call ...?
Call
POST https://graph.microsoft.com/beta/managedDevices/dd9615c4-9d3b-4ece-9272-34a10e8fe908/deviceCompliancePolicyStates/
{
"#odata.type": "#microsoft.graph.deviceCompliancePolicyState",
"settingStates": [
{
"#odata.type": "microsoft.graph.deviceCompliancePolicySettingState",
"setting": "Setting value",
"instanceDisplayName": "Instance Display Name value",
"state": "notApplicable",
"errorCode": 9,
"errorDescription": "Error Description value",
"userPrincipalName": "User Principal Name value",
"sources": [
{
"#odata.type": "microsoft.graph.settingSource",
"id": "Id value",
"displayName": "Display Name value"
}
]
}
],
"displayName": "Display Name value",
"version": 7,
"platformType": "androidForWork",
"state": "notApplicable",
"settingCount": 12
}
RESPONSE
{
"error": {
"code": "No method match route template",
"message": "No OData route exists that match template ~/entityset/key/navigation with http verb POST for request /StatelessDeviceConfigurationFEService/managedDevices('dd9615c4-9d3b-4ece-9272-34a10e8fe908')/deviceCompliancePolicyStates.",
"innerError": {
"request-id": "544c4ee2-a6de-4203-9c30-c3e589b77713",
"date": "2017-05-24T15:48:30"
}
}
}

I'm an engineer on the Microsoft Intune team specifically working on the integration between Microsoft Graph and Microsoft Intune.
In this case it looks like there is an issue with the documentation as deviceCompliancePolicyState entity can not be created, it is read-only entity that shows the state of a device compliance policy. I will work to get the documentation corrected. If you can let me know what scenario you were trying to accomplish by creating a deviceCompliancePolicyState entity I may be able to point you in the right direction.
Hope that helps
Peter

Related

Microsoft Booking Appointment Graph API -Only Post Request Not working

when I trying to create Microsoft Booking Appointment through Graph API
Only Post Request Not working .
GET , PATCH , DELETE Reuqest are working fine
through postman
same post request is working find on graph explorer platform . but not on posmant with
my auth token
my post API
https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/XXXXXXXXXXXXXXX.com/appointments
and body (took example from here)
excluded optional properties like servicename and customers
{
"#odata.type": "#microsoft.graph.bookingAppointment",
"customerTimeZone": "America/Chicago",
"smsNotificationsEnabled": false,
"endDateTime": {
"#odata.type": "#microsoft.graph.dateTimeTimeZone",
"dateTime": "2023-01-02T14:30:00.0000000",
"timeZone": "UTC"
},
"isLocationOnline": true,
"optOutOfCustomerEmail": false,
"anonymousJoinWebUrl": null,
"postBuffer": "PT10M",
"preBuffer": "PT5M",
"price": 10,
"priceType#odata.type": "#microsoft.graph.bookingPriceType",
"priceType": "fixedPrice",
"reminders#odata.type": "#Collection(microsoft.graph.bookingReminder)",
"reminders": [
{
"#odata.type": "#microsoft.graph.bookingReminder",
"message": "This service is tomorrow",
"offset": "P1D",
"recipients#odata.type": "#microsoft.graph.bookingReminderRecipients",
"recipients": "allAttendees"
},
{
"#odata.type": "#microsoft.graph.bookingReminder",
"message": "Please be available to enjoy your lunch service.",
"offset": "PT1H",
"recipients#odata.type": "#microsoft.graph.bookingReminderRecipients",
"recipients": "customer"
},
{
"#odata.type": "#microsoft.graph.bookingReminder",
"message": "Please check traffic for next cater.",
"offset": "PT2H",
"recipients#odata.type": "#microsoft.graph.bookingReminderRecipients",
"recipients": "staff"
}
],
"serviceId": "XXXXXXXXXXXXXXXXXXXXX",
"serviceLocation": {
"#odata.type": "#microsoft.graph.location",
"address": {
"#odata.type": "#microsoft.graph.physicalAddress",
"city": "Buffalo",
"countryOrRegion": "USA",
"postalCode": "98052",
"postOfficeBox": null,
"state": "NY",
"street": "123 First Avenue",
"type#odata.type": "#microsoft.graph.physicalAddressType",
"type": null
},
"coordinates": null,
"displayName": "Customer location",
"locationEmailAddress": null,
"locationType#odata.type": "#microsoft.graph.locationType",
"locationType": null,
"locationUri": null,
"uniqueId": null,
"uniqueIdType#odata.type": "#microsoft.graph.locationUniqueIdType",
"uniqueIdType": null
},
"serviceNotes": "Customer requires punctual service.",
"startDateTime": {
"#odata.type": "#microsoft.graph.dateTimeTimeZone",
"dateTime": "2023-01-02T14:00:00.0000000",
"timeZone": "UTC"
},
"maximumAttendeesCount": 1,
"filledAttendeesCount": 1
}

POST request failed from Postman to Jdoodle API

I have created an account on jdoodle and buy a free plan in which we can make 200 requests per days and from there I got credentials (clientId and clientSecret) for making request to their api .
I am making post request from postman to Jdoodle api. It is giving me response as unauthorized request with status code 401 in spite of valid credentials.
Giving me unauthorised request error also when i make request for checking credits used or (how many calls I have made to their api).
POST- https://api.jdoodle.com/v1/execute/
{
"clientID" : "83xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"clientSecret" : "30xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"script" : "console.log('hello')",
"language" : "nodejs",
"versionIndex" : "0"
}
Response I am getting is -
{
"error": "Unauthorized Request",
"statusCode": 401
}
POST- https://api.jdoodle.com/v1/credit-spent
{
"clientID" : "83xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"clientSecret" : "30xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
}
Response I am getting is -
{
"error": "Unauthorized Request",
"statusCode": 401
}
I don't know why I am getting such response inspite of all valid credentials and parameters.
Use this postman collection. Mostly it looks like your issue is with auth. make sure if client_id and secret are safely substituted.
{
"auth": null,
"event": null,
"info": {
"_postman_id": null,
"description": null,
"name": "JDoodle Compiler API.http",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"version": null
},
"item": [
{
"description": null,
"event": null,
"id": null,
"name": "Execute Program",
"protocolProfileBehavior": null,
"request": {
"auth": null,
"body": {
"disabled": null,
"file": null,
"formdata": null,
"graphql": null,
"mode": "raw",
"options": {
"language": "json"
},
"raw": "{\"clientId\": \"{{clientId}}\", \"clientSecret\": \"{{clientSecret}}\", \"script\": \"print 'hello'\", \"language\": \"python2\", \"versionIndex\": \"0\"}",
"urlencoded": null
},
"certificate": null,
"description": "Execute Program",
"header": [
{
"description": null,
"disabled": false,
"key": "content-type",
"value": "application/json"
}
],
"method": "POST",
"proxy": null,
"url": "https://api.jdoodle.com/v1/execute/"
},
"response": null,
"variable": null,
"auth": null,
"item": null
}
],
"protocolProfileBehavior": null,
"variable": [
{
"description": null,
"disabled": false,
"id": null,
"key": "baseUrl",
"name": null,
"system": null,
"type": null,
"value": "httpsDefaultParameterValue:DefaultParameterValue#DefaultParameterValue.myshopify.com/"
},
{
"description": null,
"disabled": false,
"id": null,
"key": "id",
"name": null,
"system": null,
"type": null,
"value": "<post>"
},
{
"description": null,
"disabled": false,
"id": null,
"key": "event_id",
"name": null,
"system": null,
"type": null,
"value": "<>"
}
]
}
With dothttp request is far simple and easily sharable
#name("Execute Program")
POST "https://api.jdoodle.com/v1/execute/"
json({
"clientId": "{{clientId}}",
"clientSecret": "{{clientSecret}}",
// "script": '<?php echo "hello"; ?>',
// "language": "php",
"script" :"print 'hello'",
"language": "python2",
// "stdin": "",
"versionIndex": "0"
})

how to convert json response to List in c# RestSharp

Currently I am working on asp .NET 5 console application with Restsharp, My Api Get request is working on postman, but I am struggling to convert this json object to a list .
This is my json object:
"data": {
"domain": "intel.com",
"disposable": false,
"webmail": false,
"accept_all": false,
"pattern": "{first}.{last}",
"organization": "Intel",
"country": "US",
"state": null,
"emails": [
{
"value": "danielle.sikich#intel.com",
"type": "personal",
"confidence": 99,
"sources": [
{
"domain": "github.com",
"uri": "http://github.com/hpc/mpifileutils",
"extracted_on": "2021-10-28",
"last_seen_on": "2021-10-28",
"still_on_page": true
}
],
"first_name": "Danielle",
"last_name": "Sikich",
"position": null,
"seniority": null,
"department": null,
"linkedin": null,
"twitter": null,
"phone_number": null,
"verification": {
"date": "2021-11-05",
"status": "valid"
}
},
I tried this but its not working:
List<Job> JobList = JsonConvert.DeserializeObject<List<Job>>(jsonResponse["data"]["emails"]["value"].ToString());

ASPNET Core 3.x - Appending data to all API responses

I've been googling for past 3 hours and I couldn't find anything helpful.
I'm trying to transform all my requests to a specific RESTful standard.
Right now, each and every controller returns data in this format:
[
{
"id": 3,
"title": "Test",
"content": "Content Test",
"userId": 1,
"user": null,
"categoryId": null,
"category": null,
"comments": null,
"tags": null,
"createdOn": null,
"updatedOn": null
}
]
What I want is to wrap all of these responses in a container, that also consists of metadata - as seen below:
{
"statusCode": 200,
"statusMessage": "success",
"meta":
{
"count": 1,
"total": 1,
"pagination":
{
"page": 1,
"pages": 1,
"limit": 20
},
"filters": [],
"sorters": []
},
"data":
{
[
{
"id": 3,
"title": "Test",
"content": "Content Test",
"userId": 1,
"user": null,
"categoryId": null,
"category": null,
"comments": null,
"tags": null,
"createdOn": null,
"updatedOn": null
}
]
}
}
Is the proper approach to just make a class called ResponseContainer and make all controllers return it? Because I feel like that's a viable solution.
In one of my projects, I used a generic class as response, such as MyApiResponse<T>. This class contains properties for meta data like the HttpStatusCode of the response, error messages, etc. They are set upon each response.
Within this class, I have a List<T> called Data.
Each API method returns MyApiResponse<T> where T is being the concrete data class. For instance, it could be MyApiResponse<Weather> where Data would store a List<Weather.
I'll definetly use this approach for my next API project as well.

Order ID in shopify webhooks

I'm trying to integrate my app with shopify shop. So far, i configured webhooks to send data to my app on certain system events - like creating an order.
Everything is working just great with one exception - i can't understand how to get the order ID from those webhooks. There is no any param present in them that looks like an order id which i later need to use in any requests to shopify API to retrieve info about the order.
Example webhook (order-created event):
{
"id": 488245657691,
"email": "",
"closed_at": null,
"created_at": "2018-05-10T14:05:02-04:00",
"updated_at": "2018-05-10T14:05:03-04:00",
"number": 6,
"note": "raz dwa trzy",
"token": "xxx",
"gateway": "manual",
"test": false,
"total_price": "2000.00",
"subtotal_price": "2000.00",
"total_weight": 0,
"total_tax": "373.98",
"taxes_included": true,
"currency": "PLN",
"financial_status": "paid",
"confirmed": true,
"total_discounts": "0.00",
"total_line_items_price": "2000.00",
"cart_token": null,
"buyer_accepts_marketing": false,
"name": "#1006",
"referring_site": null,
"landing_site": null,
"cancelled_at": null,
"cancel_reason": null,
"total_price_usd": "555.69",
"checkout_token": null,
"reference": null,
"user_id":"",
"location_id":"",
"source_identifier": null,
"source_url": null,
"processed_at": "2018-05-10T14:05:02-04:00",
"device_id": null,
"phone": null,
"customer_locale": null,
"app_id": "",
"browser_ip": null,
"landing_site_ref": null,
"order_number": 1006,
"discount_codes": [],
"note_attributes": [],
"payment_gateway_names": [
"manual"
],
"processing_method": "manual",
"checkout_id": null,
"source_name": "shopify_draft_order",
"fulfillment_status": null,
"tax_lines": [
{
"title": "VAT",
"price": "373.98",
"rate": 0.23
}
],
"tags": "",
"contact_email": null,
"order_status_url": "",
"line_items": [
{
"id": 1241199411291,
"variant_id": 8135591723099,
"title": "Above elbow glass",
"quantity": 1,
"price": "2000.00",
"sku": "",
"variant_title": null,
"vendor": "",
"fulfillment_service": "manual",
"product_id": 750373666907,
"requires_shipping": true,
"taxable": true,
"gift_card": false,
"name": "Above elbow glass",
"variant_inventory_management": null,
"properties": [],
"product_exists": true,
"fulfillable_quantity": 1,
"grams": 0,
"total_discount": "0.00",
"fulfillment_status": null,
"tax_lines": [
{
"title": "VAT",
"price": "373.98",
"rate": 0.23
}
]
}
],
"shipping_lines": [],
"fulfillments": [],
"refunds": []
}
The only params that looks like might be handy are token and order_number but token is probably nor what i'm looking for, just like the order_number. Third one is id but, based on shopify docs, id is a webhook id, not order id. Do you have any idea on how can i obtain such order ID from the webhook?
Just like the domain the webhook is coming from, the order ID is in the header. That will help you out. Simply grab the order ID from there, and move on.
example:
domain = request.env['HTTP_X_SHOPIFY_SHOP_DOMAIN']
order_id = request.env['HTTP_X_SHOPIFY_ORDER_ID']