I have a method in controller creat
it respond generate array of records like
[{"code"=>500, "body"=>{"message"=>"Ivalid data or you enter a duplicate data"}}, {"code"=>200, "body"=>{"id"=>"775606be-d3ae-4b43-a820-74022f8f273f"}}, {"code"=>500, "body"=>{"message"=>["Name has already been taken"]}}, {"code"=>500, "body"=>{"message"=>[:Error, ["No Fable", "level not found in rand", "Invalid or Blank e"]]}}]
now I want to make it n a json response
def create
k=[{"code"=>500, "body"=>{"message"=>"Ivalid data or you enter a duplicate data"}}, {"code"=>200, "body"=>{"id"=>"775606be-d3ae-4b43-a820-74022f8f273f"}}, {"code"=>500, "body"=>{"message"=>["Name has already been taken"]}}, {"code"=>500, "body"=>{"message"=>[:Error, ["No Federation ID in Cookie ID\n# Mapping Table", "level not found in Brand", "Invalid or Blank Source Type"]]}}]
# render create.json.jbuilder
render json: k, status: 200
end
so it generate
{
"bulks": [
{
"code": 500,
"body": {
"message": "Ivalid data or you enter a duplicate data"
}
},
{
"code": 200,
"body": {
"id": "7754322222222f"
}
},
{
"code": 500,
"body": {
"message": [
"Name has already been taken"
]
}
},
{
"code": 500,
"body": {
"message": [
"Error",
[
"No Fable",
"level not found in Brand",
"Invalid or Blank Source Type"
]
]
}
}
]
}
it added bulks: while render the json in controller
how can I remove the bulks the expected json would be
{ {
"code": 500,
"body": {
"message": "Ivalid data or you enter a duplicate data"
}
},
{
"code": 200,
"body": {
"id": "775606be-d3ae-4b43-a820-74022f8f273f"
}
},
{
"code": 500,
"body": {
"message": [
"Name has already been taken"
]
}
},
{
"code": 500,
"body": {
"message": [
"Error",
[
"No Fable",
"level not found in Brand",
"Invalid or Blank Source Type"
]
]
}
} }
Please help
Related
After annotating my data set and training a custom processor on Google Document AI, I get the following error message after 40 mins:
{
"name": "projects/500809854407/locations/eu/operations/10980743890623751388",
"done": true,
"result": "error",
"response": {},
"metadata": {
"#type": "type.googleapis.com/google.cloud.documentai.uiv1beta3.TrainProcessorVersionMetadata",
"commonMetadata": {
"state": "FAILED",
"createTime": "2023-01-13T15:11:36.505757Z",
"updateTime": "2023-01-13T15:50:10.343765Z",
"resource": "projects/500809854407/locations/eu/processors/b94da5023b6cb35d/processorVersions/98637063da2b64d4"
},
"trainingDatasetValidation": {},
"testDatasetValidation": {}
},
"error": {
"code": 13,
"message": "Internal error encountered.",
"details": []
}
}
Any idea what could be the problem?
I can successfully create a name range using batchUpdate api, however, replaceNameRangeContent gives the following error:
{ "error": { "code": 400, "message": "Invalid requests[0].replaceNamedRangeContent: Named range with ID kix.ydbik9q4xmna contains content that cannot be replaced.", "status": "INVALID_ARGUMENT" } }
The request for this was:
{ "requests": [ { "replaceNamedRangeContent": { "namedRangeId": "kix.ydbik9q4xmna", "text": "" } } ] }
Am I using the API properly? I created the name range giving start/endindex and naming it. It creates the NameRangeId that I used in the replace content post.
There was content in the index range above. However, below is a sample doc structure for an empty doc (with doc styles, etc. omitted). I tried a
{
"requests": [
{
"createNamedRange": {
"range": {
"startIndex": 1,
"endIndex": 2
},
"name": "ApplicantName"
}
}
]
}
followed by
{
"requests": [
{
"replaceNamedRangeContent": {
"namedRangeId": "kix.f7g9w0sr3kyp",
"text": "Applicant Name"
}
}
]
}
and get the same error. But when doing the create named range it would not accept any start/end index besides 1 and 2.
I must not understand the actual intent of named ranges!
Sample:
{
"title": "Test mule",
"body": {
"content": [
{
"endIndex": 1,
"sectionBreak": {
"sectionStyle": {
"columnSeparatorStyle": "NONE",
"contentDirection": "LEFT_TO_RIGHT",
"sectionType": "CONTINUOUS"
}
}
},
{
"startIndex": 1,
"endIndex": 2,
"paragraph": {
"elements": [
{
"startIndex": 1,
"endIndex": 2,
"textRun": {
"content": "\n",
"textStyle": {}
}
}
],
"paragraphStyle": {
"namedStyleType": "NORMAL_TEXT",
"direction": "LEFT_TO_RIGHT"
}
}
}
]
}
I can reproduce your error when creating a named range with "startIndex": 0
Mind that indices for paragraphs (and thus text) in Google Docs refer to the position of a character in the text and start with 1.
So if you create a name range specifying the indices correctly, you will not get the error mesage
{ "error": { "code": 400, "message": "Invalid requests[0].replaceNamedRangeContent: Named range with ID kix.ydbik9q4xmna contains content that cannot be replaced.", "status": "INVALID_ARGUMENT" } }
Sample request for creating named ranges:
{
"requests": [
{
"createNamedRange": {
"range": {
"startIndex": 5,
"endIndex": 7
},
"name": "test3"
}
}
]
}
I have some code that was working just fine a few months ago, but something in the Graph API has changed and this no longer works. I am trying to create a message in an existing folder, by doing a POST to this url:
https://graph.microsoft.com/v1.0/users/jjones#transend.onmicrosoft.com/mailFolders/AAMkADNjAAA=/messages
(folder id shortened)
The call fails with http error 400, and the returned error is "UnableToDeserializePostBody". The input json is shown below. By experimentation I was able to trace the problem specifically to "singleValueExtendedProperties". I normally put several properties there, but for this test I removed all but the one you see. I have tried other properties as well, they all fail. This seems like some stupid formatting error but I can't see it. Any help appreciated.
{
"subject": "Test again",
"Sender": {
"emailAddress": {
"name": "John Doe",
"address": "missing#domain.com"
}
},
"body": {
"contentType": "TEXT",
"content": "This is a text message."
},
"toRecipients": [
{
"emailAddress": {
"name": "Jane Smith",
"address": "missing#domain.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"name": "Bob Jones",
"address": "missing#domain.com"
}
}
],
"singleValueExtendedProperties": [
{
"propertyId": "SystemTime 0x0039",
"value": "1998-07-29T21:30:00.0000+00:00"
}
],
"importance": "normal"
}
The main problem here is you are specifying the property('propertyid') in singleValueExtendedProperties object is not valid. There are only 2 properties in singleValueExtendedProperties. One is id and the other is value.
Replace 'propertyId' with id.
I have tested it in POSTMAN with your payload changing the propertyId to id and it worked.
Request Body:-
{
"subject": "Test again",
"Sender": {
"emailAddress": {
"name": "John Doe",
"address": "missing#domain.com"
}
},
"body": {
"contentType": "TEXT",
"content": "This is a text message."
},
"toRecipients": [
{
"emailAddress": {
"name": "Jane Smith",
"address": "missing#domain.com"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"name": "Bob Jones",
"address": "missing#domain.com"
}
}
],
"singleValueExtendedProperties": [
{
"id": "SystemTime 0x0039",
"value": "1998-07-29T21:30:00.0000+00:00"
}
],
"importance": "normal"
}
Current steps for creating task are
POST /planner/tasks
GET /planner/tasks/{id from post call}/details
PATCH /planner/tasks/{id from post call}/details
If-Match: {etag from get call}
but I want to batch three steps in single call using https://developer.microsoft.com/en-us/graph/docs/concepts/json_batching
And according to odata v4 references http://docs.oasis-open.org/odata/odata-json-format/v4.01/csprd02/odata-json-format-v4.01-csprd02.html#sec_ReferencingNewEntities we can refer entities in same batch call using ${id of other request}
{
"requests": [
{
"id": "task",
"url": "/planner/tasks",
"body": {
"title": "asff",
"appliedCategories": {
"category5": true
},
"planId": "mSV7ODf3g0iTJrUtsNcvHZYAB-ZW",
"bucketId": "WFN6kxMykE-4xxqLUh1uS5YALCWq",
"assignments": {
"4393baf8-8a52-4164-bf93-b1cba5130329": {
"#odata.type": "#microsoft.graph.plannerAssignment",
"orderHint": " !"
}
},
"dueDateTime": "2018-04-23T18:30:00.000Z"
},
"method": "POST",
"headers": {
"Content-Type": "application/json"
}
},
{
"id": "getDetail",
"method": "GET",
"dependsOn": [
"task"
],
"url": "/planner/tasks/$task/details"
},
{
"id": "patchDetail",
"dependsOn": [
"getDetail"
],
"url": "/planner/tasks/$task/details",
"method": "PATCH",
"headers": {
"Content-Type": "application/json",
"if-match": "$getDetail"
},
"body": {
"description": "gwrthbetrhnety"
}
}
}
]
}
but Get details call is failing with error
{
"id": "getDetail",
"status": 400,
"body": {
"error": {
"code": "BadRequest",
"message": "The request URI is not valid. Since the segment 'tasks' refers to a collection, this must be the last segment in the request URI or it must be followed by an function or action that can be bound to it otherwise all intermediate segments must refer to a single resource.",
"innerError": {
"request-id": "a46ce528-993f-4cff-865e-98b2b98d5f23",
"date": "2018-04-17T10:38:29"
}
}
}
}
What I'm doing wrong here
I believe what is missing is the URI (should be POST https://graph.microsoft.com/v1.0/$batch instead of POST /planner/tasks) and "id" field has to be numeric. Check out MS documentation:
https://learn.microsoft.com/en-us/graph/json-batching?context=graph%2Fapi%2F1.0&view=graph-rest-1.0
Here is an example of combining POST and GET in a batch call
I'm trying to create a windowsMobileMSI app in intune.
I use the following JSON:
{
"#odata.type": "#microsoft.graph.windowsMobileMSI",
"displayName": "API uploaded Package",
"description": "Desc of Api uploaded pkg",
"publisher": "publisher 1",
"isFeatured": false,
"privacyInformationUrl": "",
"informationUrl": null,
"owner": "owner 1",
"developer": "dev 1",
"notes": "no notes",
//File info
"committedContentVersion": "1",
"fileName": "PackageProvider.msi",
"size": 409664,
"identityVersion": "1.0.8",
"commandLine": "",
"productCode": "{cc12adbd-8692-458d-b186-9d83b639ff1d}",
"productVersion": "1.0.8",
"ignoreVersionDetection": false
}
However when I post it to
POST https://graph.microsoft.com/beta/deviceAppManagement/mobileApps
I get the error message
{
"error": {
"code": "BadRequest",
"message": "An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000000000 - Activity ID: fd5ee560-f4da-4255-b893-aa133c60fe4b - Url: https://fef.amsub0102.manage.microsoft.com/StatelessAppMetadataFEService/deviceAppManagement/mobileApps?api-version=5017-10-18 - CustomApiErrorPhrase: ",
"innerError": {
"request-id": "fd5ee560-f4da-4255-b893-aa133c60fe4b",
"date": "2017-12-22T08:31:35"
}
}
}
I took the lines below the "//File info" comment from an existing windowsMobileMSI app.
I tried removing of these lines but it didn't help me.
Can anyone advise me what is wrong with my JSON?
I've got an advice to use only the "identityVersion" after the //File info.
So here's the JSON that works now:
{
"#odata.type": "#microsoft.graph.windowsMobileMSI",
"displayName": "API uploaded Package",
"description": "Desc of Api uploaded pkg",
"publisher": "publisher 1",
"isFeatured": false,
"privacyInformationUrl": "",
"informationUrl": null,
"owner": "owner 1",
"developer": "dev 1",
"notes": "no notes",
//File info
"identityVersion": "1.0.8",
}
Try removing "size": 409664 from the JSON.