Invalid patch error in Contentful CMA client - patch

I am trying to populating an empty field by using patch method in Contentful. The following piece of code works in one cloned environment but does not work in another.
let patchData: OpPatch[] = [
{
op: 'replace',
path: '/fields/keywords',
value: entryKeyword,
},
];
await cmaClient.entry.patch({ entryId: entryId }, patchData, { 'X-Contentful-Version': entryVersion });
When I try to execute this, receiving a 'Unprocessable Entity' error:
UnprocessableEntity: {
"status": 422,
"statusText": "Unprocessable Entity",
"message": "Could not apply patch to entry: invalid patch",
"details": {},
"request": {
"url": "/spaces/xyz/environments/abc/entries/123456789",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json-patch+json",
"X-Contentful-User-Agent": "sdk contentful-management-plain.js/7.54.2;",
"Authorization": "Bearer ...",
"user-agent": "node.js/v14.19.2",
"Accept-Encoding": "gzip",
"X-Contentful-Version": 25,
"Content-Length": 78
},
"method": "patch",
"payloadData": "[{\"op\":\"replace\",\"path\":\"/fields/keywords\",\"value\":\"test keyword\"}]"
},
"requestId": "abcd-123456"
}
I have the same exact access permissions to both environments. What am I missing out on?

I had the same issue - turned out when the entry doesn't have the filed you're trying to patch - it will throw an error like above.

Related

Firebase Firestore REST POST Request - Query and Filter using structured query

URL:
https://firestore.googleapis.com/v1beta1/projects/projectname/databases/(default)/documents/:runQuery
POST buffer:
{ "structuredQuery": {"from": [{"collectionId": "example","allDescendants": true}],"where": {"fieldFilter": {"field": {"fieldPath": "Invoiceno"},"op": EQUAL,"value": {"stringValue": "1"}}}}}
Response:
[{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"{ \"structuredQuery\": {\"from\": [{\"collectionId\": \"example\",\"allDescendants\": true}],\"where\": {\"fieldFilter\": {\"field\": {\"fieldPath\": \"Invoiceno\"},\"op\": EQUAL,\"value\": {\"stringValue\": \"1\"}}}}}\": Cannot bind query parameter. Field '{ \"structuredQuery\": {\"from\": [{\"collectionId\": \"example\",\"allDescendants\": true}],\"where\": {\"fieldFilter\": {\"field\": {\"fieldPath\": \"Invoiceno\"},\"op\": EQUAL,\"value\": {\"stringValue\": \"1\"}}}}}' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"{ \"structuredQuery\": {\"from\": [{\"collectionId\": \"example\",\"allDescendants\": true}],\"where\": {\"fieldFilter\": {\"field\": {\"fieldPath\": \"Invoiceno\"},\"op\": EQUAL,\"value\": {\"stringValue\": \"1\"}}}}}\": Cannot bind query parameter. Field '{ \"structuredQuery\": {\"from\": [{\"collectionId\": \"example\",\"allDescendants\": true}],\"where\": {\"fieldFilter\": {\"field\": {\"fieldPath\": \"Invoiceno\"},\"op\": EQUAL,\"value\": {\"stringValue\": \"1\"}}}}}' could not be found in request message."
}
]
}
]
}
}
]
I have given this for POST REST function, but i am unable to get the data.
I believe the issue is in your fieldFilter, where you are using the op as EQUAL and it should be "EQUAL" with quotes, try changing it to the following and it should work:
"fieldFilter":
{
"field":
{
"fieldPath": "Invoiceno"
},
"op": "EQUAL",
"value": {"stringValue": "1"}
}
I discover you need to create an index on root Document.
So when you run the query all is fine.
https://firestore.googleapis.com/v1/projects/{projectId}/databases/(default)/documents:runQuery
"fieldFilter":
{
"field":
{
"fieldPath": "Invoiceno"
},
"op": "EQUAL",
"value": {"stringValue": "1"}
}{ "structuredQuery": {"from": [{"collectionId": "example","allDescendants": true}],"where": {"fieldFilter": {"field": {"fieldPath": "Invoiceno"},"op": EQUAL,"value": {"stringValue": "1"}}}}}

Add user to SharePoint group using Power Automate

I would like to use Power Automate to add a user in as a member to a SharePoint Site using HTTP request.
The flow continues to fail on me and I'm wondering if anyone managed to do this successfully in the past?
I got the Group ID from :
https://{org name}.sharepoint.com/sites/{site name}/_api/web/id
I have attached included the input and output of the HTTP Request (within flow) below
Raw Inputs
{
"host": {
"connectionReferenceName": "shared_sharepointonline",
"operationId": "HttpRequest"
},
"parameters": {
"dataset": "https://{REDACTED}.sharepoint.com/",
"parameters/method": "POST",
"parameters/uri": "_api/web/sitegroups(547ea631-f9d4-411a-a3f5-8af3d5e6225b)/Users",
"parameters/headers": {
"accept": "application/json;odata.metadata=none",
"content-type": "application/json"
},
"parameters/body": "{'LoginName':'i:0#.f|membership|{REDACTED}#{REDACTED}.com'}"
}
}
Raw Outputs
{
"statusCode": 400,
"headers": {
"Pragma": "no-cache",
"x-ms-request-id": "cb6ab59f-909a-2000-ac2f-2217e416179a",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
"Cache-Control": "no-store, no-cache",
"Set-Cookie": "{REDACTED};Path=/;HttpOnly;Secure;Domain=sharepointonline-we.azconn-we.p.azurewebsites.net,ARRAffinitySameSite={REDACTED}24;Path=/;HttpOnly;SameSite=None;Secure;Domain=sharepointonline-we.azconn-we.p.azurewebsites.net",
"Timing-Allow-Origin": "*",
"x-ms-apihub-cached-response": "true",
"Date": "{TIME & DATE}",
"Content-Length": "457",
"Content-Type": "application/json",
"Expires": "-1"
},
"body": {
"status": 400,
"message": "The expression \"web/sitegroups(547ea631-f9d4-411a-a3f5-8af3d5e6225b)/Users\" is not valid.\r\nclientRequestId: 1cc16a39-7d9c-4290-b07d-4c7329611fb8\r\nserviceRequestId: cb6ab59f-909a-2000-ac2f-2217e416179a",
"source": "https://{REDACTED}.sharepoint.com/_api/web/sitegroups(547ea631-f9d4-411a-a3f5-8af3d5e6225b)/Users",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}
}
The error I get is:
"The expression "web/sitegroups(547ea631-f9d4-411a-a3f5-8af3d5e6225b)/Users" is not valid.
clientRequestId: 1cc16a39-7d9c-4290-b07d-4c7329611fb8
serviceRequestId: cb6ab59f-909a-2000-ac2f-2217e416179a"
This makes me think the group ID is incorrect. Can someone please advise if this is incorrect or if I have maybe formatted the uri incorrectly?
Try to use the body like this:
{
'__metadata': {
// Type that you are modifying.
'type': 'SP.User'
},
'LoginName': '<<User Login Name>>'
}

LinkedIn Assets API: No AWS key returned when registering multi-part upload

I'm trying to upload a video > 200MB via https://api.linkedin.com/v2/assets. When registering a MULTIPART_UPLOAD I do not receive the "x-amz-server-side-encryption" or "x-amz-server-side-encryption-aws-kms-key-id" headers information anywhere in the response. I do get those when registering a SINGLE_REQUEST_UPLOAD and I'm able to successfully upload a video file < 200MB using that mechanism.
Example response for registering a multi-part upload:
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MultipartUpload": {
"metadata": "{METADATA}",
"partUploadRequests": [
{
"headers": {
"Content-Length": "5242880",
"Content-Type": "application/octet-stream"
},
"urlExpiresAt": 1547231882996,
"byteRange": {
"lastByte": 5242879,
"firstByte": 0
},
"url": "{AWS_UPLOAD_URL}"
},
{
"headers": {
"Content-Length": "5242880",
"Content-Type": "application/octet-stream"
},
"urlExpiresAt": 1547231882996,
"byteRange": {
"lastByte": 10485759,
"firstByte": 5242880
},
"url": "{AWS_UPLOAD_URL}"
},
{
"headers": {
"Content-Length": "3585789",
"Content-Type": "application/octet-stream"
},
"urlExpiresAt": 1547231883023,
"byteRange": {
"lastByte": 580302588,
"firstByte": 576716800
},
"url": "{AWS_UPLOAD_URL}"
}
]
}
},
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:{ASSET_URN},urn:li:digitalmediaMediaArtifactClass:aws-userUploadedVideo)",
"asset": "urn:li:digitalmediaAsset:{ASSET_URN}"
}
}
I have tried to upload to those urls without the two headers and get a 403 Forbidden response saying I'm missing signed headers. The "x-amz-server-side-encryption" and "x-amz-server-side-encryption-aws-kms-key-id" should be returned in the register response right? If not, how do I make requests to aws without them?

Simulator error UnparseableJsonResponse ("Cannot find field.")

I have successfully tested the first few intents of my app with my webhook in the DialogFlow console, but testing in the Simulator gives the following error:
UnparseableJsonResponse API Version 2: Failed to parse JSON response
string with 'INVALID_ARGUMENT' error: ": Cannot find field.".
NB!!!
The first thing to notice is that it refers to "API Version 2".
No requests are reaching my webhook - so it appears that this is all within Google.
Using Chrome Developer Tools, I see the Network entry that gets this error response - some details below:
Request url from Simulator: https://assistant.clients6.google.com/v1/assistant:converse?alt=json&key=A.....
NB!!!
(Note it says 'v1')
Request Payload:
{"conversationToken":"","debugLevel":1,"inputType":"KEYBOARD","locale":"en-US","mockLocation":{"city":"Mountain View","coordinates":{"latitude":37.421980615353675,"longitude":-122.08419799804688},"formattedAddress":"Googleplex, Mountain View, CA 94043, United States","zipCode":"94043"},"query":"Talk to ","surface":"PHONE"}
Response:
{
"response": "Connect the docs isn't responding right now. Try again soon.",
"conversationToken": "GidzaW11bGF0b3JfZGV2aWNlXzM3MTQxRERFM0I0Nzk1Q0ZfMDAwMDA=",
"audioResponse": "//NExAAR... encoded audio ...",
"debugInfo": {
"assistantToAgentDebug": {
"curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=...token...' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: ...authorization key...' -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"...user id...\",\"locale\":\"en-US\",\"lastSeen\":\"2017-12-15T17:22:55Z\"},\"conversation\":{\"conversationId\":\"1513778713541\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"Talk to Connect The Docs\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}]}'",
"assistantToAgentJson": "{\"user\":{\"userId\":\"...user id...\",\"locale\":\"en-US\",\"lastSeen\":\"2017-12-15T17:22:55Z\"},\"conversation\":{\"conversationId\":\"1513778713541\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"Talk to Connect The Docs\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}]}"
},
"agentToAssistantDebug": {
"agentToAssistantJson": "{\"message\":\"Unexpected apiai response format: Empty speech response\",\"apiResponse\":{\"id\":\"24ddbf1c-3930-40c6-ba50-03c0935cd1d0\",\"timestamp\":\"2017-12-20T14:05:13.766Z\",\"lang\":\"en-us\",\"result\":{},\"status\":{\"code\":200,\"errorType\":\"success\"},\"sessionId\":\"1513778713541\"}}"
},
"sharedDebugInfo": [{
"name": "ResponseValidation",
"subDebugEntry": [{
"name": "UnparseableJsonResponse",
"debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\"."
}]
}]
},
"visualResponse": {}
}
I have been informed by Google Support that I am indeed using version V2 - I initiated this in December 2017 - long after the May 2017 "cutoff date" where V2 is supposed to be the default.
Is this a Google bug? Have I missed something setting up my intents? Or is there another setting that may be causing this?
I see that other posts in the DialogFlow forum show the same problem.
Any help is appreciated.
Added on 1/9/2018:
Contents of the Debug Tab:
{
"agentToAssistantDebug": {
"agentToAssistantJson": {
"message": "Unexpected apiai response format: Empty speech response",
"apiResponse": {
"id": "64a900d2-23e8-4833-b9de-0b207f63bffc",
"timestamp": "2018-01-08T21:08:36.821Z",
"lang": "en-us",
"result": {},
"status": {
"code": 200,
"errorType": "success"
},
"sessionId": "1515445716570"
}
}
},
"assistantToAgentDebug": {
"assistantToAgentJson": {
"user": {
"userId": "ABwppHFGoTJm5fKpau6WWwufKQE5UwkebooowZF7YhvD7PPY-hUfxU2_KRpB0LLNcLPyXasbXnRxXT6fniKk",
"locale": "en-US",
"lastSeen": "2018-01-05T15:53:11Z"
},
"conversation": {
"conversationId": "1515445716570",
"type": "NEW"
},
"inputs": [
{
"intent": "actions.intent.MAIN",
"rawInputs": [
{
"inputType": "VOICE",
"query": "talk to connect the docs"
}
]
}
],
"surface": {
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
},
{
"name": "actions.capability.WEB_BROWSER"
}
]
},
"isInSandbox": true,
"availableSurfaces": [
{
"capabilities": [
{
"name": "actions.capability.AUDIO_OUTPUT"
},
{
"name": "actions.capability.SCREEN_OUTPUT"
}
]
}
]
},
"curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=0ffc8bcf72704850a4b4139d49a8d72e' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhYTQ1NDFlNGM4ZWVhODQ0NjhmZTYxYTkzZmIxYzA2MzJkYjVhMGYifQ.eyJhdWQiOiJhY3RpdmUtZG9jdW1lbnQiLCJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJqdGkiOiIwY2U2OTdlNmE3NGFiZmVmZTdiYzhmMGU2ZGJlMzEyMDFjOWU3MzA5IiwiaWF0IjoxNTE1NDQ1NzE2LCJleHAiOjE1MTU0NDU4MzYsIm5iZiI6MTUxNTQ0NTQxNn0.hZNpVrH4o8ObGIvZ7BQV44nymekTWR_K4_jsDKCzgj74z57IDyUXNGEZs6KUFxBM_2FXiSoOxJUQZ1OhDRpkpQ6L4LELYN_JDhly7kgy-SLgKgLG6FZ4YV-8qOgr9Uxmr9SsG6NSXdiG7HvTrHLXIwA8K2siBNGGDWAIB691gAC8qsjsq4d3VnHMTeqlJ6mDoOtZ2xdLnJbK5B-OK-rLHEhX6K1-Z7rXQL3OgSwUtRVvYfHI3jqY83Xn3-uf06izkQhwVqH-W6X1REltrlxFTPW2h72D-st-QQ9euIpK3fn0x-z3ouQ17g-rGrPjKcOop9FejtKMT1tibxSkQ7qywQ' -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"ABwppHFGoTJm5fKpau6WWwufKQE5UwkebooowZF7YhvD7PPY-hUfxU2_KRpB0LLNcLPyXasbXnRxXT6fniKk\",\"locale\":\"en-US\",\"lastSeen\":\"2018-01-05T15:53:11Z\"},\"conversation\":{\"conversationId\":\"1515445716570\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"VOICE\",\"query\":\"talk to connect the docs\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.WEB_BROWSER\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}]}'"
},
"sharedDebugInfo": [
{
"name": "ResponseValidation",
"subDebugEntry": [
{
"debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\".",
"name": "UnparseableJsonResponse"
}
]
}
]
}
Contents of the Validation Errors Tab:
UnparseableJsonResponse
API Version 2: Failed to parse JSON response string with
'INVALID_ARGUMENT' error: ": Cannot find field.".
Screenshot of welcome intent added 1/10/2018:
The problem is a combination of two things:
There are no text replies set in the Response section.
When the Intent is triggered, it does not get sent to a webhook.
As a result, Dialogflow replies to the Assistant with no text response, which is an error.
You can correct this by making sure your welcome intent does one of the following (you don't have to do both):
Set one or more text replies. These would be sent back when the Intent is called.
Check the Use webhook box under Fulfillment. This would call your webhook when the Intent is triggered. (And then make sure that your webhook returns a valid response.)
As you speculated in your comments, you could also change the Welcome Intent to one of your other Intents that you've already tested to respond. There is nothing special about this particular Welcome Intent - it was just the one created by default for you.

share on linkedin returns "Can not parse JSON share document"

I am trying to share a post on linkedin.
I managed to log in and get returned an id and an accessToken but when I follow the REST APIs way of sharing an update I keep getting:
Error: failed [400] {
"errorCode": 0,
"message": "Can not parse JSON share document.\nRequest body:\n\nError:\nnull",
"requestId": "NWGE7D4LSW",
"status": 400,
"timestamp": 1451699447711
}
My http POST looks like this:
HTTP.post('https://api.linkedin.com/v1/people/~/shares?format=json&oauth2_access_token=' + accessToken, {
'headers': {
'Content-Type': "application/json",
'x-li-format': "json"
},
'comment': "test!",
'visibility': {
'code': "anyone"
}
});
this worked:
HTTP.post('https://api.linkedin.com/v1/people/~/shares?format=json&oauth2_access_token=' + Meteor.user().services.linkedin.accessToken, {
headers: {
"Content-Type": "application/json",
"x-li-format": "json"
},
data: {
comment: "testing",
visibility: {
code: "anyone"
}
}
});

Resources