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

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?

Related

Integromat app {{connection.param}} not working

I am trying to setup an own App in Integromat
What is required for my App is an URL (and later a Bearer Token) to be entered manually by the user who wants to use my App.
I have the Apps Base:
{
"baseUrl": "{{connection.url}}",
"log": {
"sanitize": ["request.headers.authorization"]
}
}
a Connection:
Parameters:
[
{
"name": "url",
"label": "url",
"type": "text",
"required": true,
"value":"https://my-server"
}
]
and the Scenario:
{
"url": "/api/endpoint",
"method": "GET",
"qs": {},
"headers": "{{connection.headers}}",
"response": {
"output": "{{body}}"
}
}
When i execute, the scenario from my App. The URL seems not to be correctly taken over from the one configured inside the connection parametrs.
Can someone help?
Everything was right. I had to delete the old Connection and create a new one.

Q: Linkedin Vector Assest API, Registering Multi-Part Upload - No metadata value in response

I'm attempting to complete a multipart upload using Linkedin V2 Vector Assets and i've noticed that when registering the upload, the metadata field comes back blank in the response.
Here's the request to register the upload https://api.linkedin.com/v2/assets?action=registerUpload
{
"registerUploadRequest":{
"owner":"urn:li:organization:71736744",
"recipes":["urn:li:digitalmediaRecipe:feedshare-video"],
"serviceRelationships":[
{"identifier":"urn:li:userGeneratedContent","relationshipType":"OWNER"}
],
"supportedUploadMechanism":["MULTIPART_UPLOAD"],
"fileSize":50866165
}
and here is the response (removed all but one partUploadRequests object to make the response easier to read)
{
"value": {
"uploadMechanism": {
"com.linkedin.digitalmedia.uploading.MultipartUpload": {
"partUploadRequests": [
{
"headers": {
"Content-Type": "application/octet-stream"
},
"byteRange": { "lastByte": 4194303, "firstByte": 0 },
"url": "https://www.linkedin.com/dms-uploads/C5605AQFnYcNsf7K5Yw/uploadedVideo?sau=aHR0cHM6Ly93d3cubGlua2VkaW4uY29tL2FtYnJ5L2FtYnJ5LXZpZGVvLz94LWxpLWFtYnJ5LWVwPUFRRmp4SlBwRndkUUNnQUFBWGhjYkgwNzNuZmpacTRFM3AxUkpidTMxTlAxems3WmdoUHN1Ymp1TjVGTXVDRGFOaGczVnpHWXNpLW5OYWh2NlkxWkU5UDVIdktsQ2JxbGhhOUt1SElJSnBXTjI0TkEyWDIzM1ZiaS1aNW4yTmlXWWQyX1VlN1J2d0FEdkMwSG51ckNMY1ljMkdrczhKclFlZHRYNlZNN2dvTFJad2hpT0pxcFNZM29mXzdTTmRhZjZzQlNMS3FwaTJyWF9LYTRqTk9OcnBhTFpCam1KR3ZENEV3ZFd0VHEzN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NlFpeGZyRmpxQnYwaDhwOGZpeXZ0Q2Job0xjU1g4aWNjX0lSX28xQXR0UmZB&pn=1&m=616825227&app=86804616&sync=0&v=beta&ut=1nBLJxAvwH5FI1",
"urlExpiresAt": 1616544717116
} ...
],
"metadata": ""
}
},
"asset": "urn:li:digitalmediaAsset:C5605AQFnYcNsf7K5Yw",
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5605AQFnYcNsf7K5Yw,urn:li:digitalmediaMediaArtifactClass:uploadedVideo)"
}
}
The api documentation explains that I need to use the metadata value from the register upload response to complete the upload
I attempt making the request anyway without a value for the metadata field to https://api.linkedin.com/v2/assets?action=completeMultiPartUpload (removed all but one partUploadResponses object to make the response easier to read)
{
"completeMultipartUploadRequest": {
"mediaArtifact": "urn:li:digitalmediaMediaArtifact:(urn:li:digitalmediaAsset:C5605AQFnYcNsf7K5Yw,urn:li:digitalmediaMediaArtifactClass:uploadedVideo)",
"metadata": "",
"partUploadResponses": [
{
"headers": {
"ETag": "/ambry-video/signedId/AQGpSasdC3ezCgAAAXhcbTobXlB6_ujllr8BPUUAX4o9OgbHCxiRKoG9woM85dnGrxbUbd-5IXyMKO7syqyZXLgHFd8GQJkiMvvp1eHI9N32iJqMG-l_aFgSeXMbcqkFFcjuT22djM93dmKs_RBb58kppS3CadOPHSt5_tApCxAq0wgTfYQng3OkV_uVRdjIYftyfnHW3nF2vWz4hZBoX-YhmF6gDhXtN9dNTnU4QpHB7sGCecpjYgT8ypV-u5isvFrujHl3tl4.bin"
},
"httpStatusCode": 200
} ....
]
}
}
This comes back as a 200OK without any response body which is expected.
After that I check the upload status and which comes back with a code of SERVER_ERROR and I'm not able to create a post with the asset id of the uploaded asset.
Response from checking asset status https://api.linkedin.com/v2/assets/C5605AQFnYcNsf7K5Yw
{
"recipes": [
{
"recipe": "urn:li:digitalmediaRecipe:feedshare-video",
"status": "SERVER_ERROR"
}
],
"serviceRelationships": [
{
"relationshipType": "OWNER",
"identifier": "urn:li:userGeneratedContent"
}
],
"mediaTypeFamily": "VIDEO",
"created": 1616458317042,
"id": "C5605AQFnYcNsf7K5Yw",
"lastModified": 1616458454711,
"status": "ALLOWED"
}
Request to create a UGC post with the asset https://api.linkedin.com/v2/assets
{
"author": "urn:li:organization:71736744",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"media": [
{
"media": "urn:li:digitalmediaAsset:C5605AQFnYcNsf7K5Yw",
"status": "READY",
"title": {
"attributes": [],
"text": "Sample Video Create"
}
}
],
"shareCommentary": {
"attributes": [],
"text": "Some share text"
},
"shareMediaCategory": "VIDEO"
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
Response to the request
{
"serviceErrorCode": 0,
"message": "Resource assets does not exist",
"status": 404}
The only thing I can think of is since I don't have a metadata value when completing the upload I'm not able to use the video asset in UGC posts. Anyone encountered a problem similar to this?
Further Investigations
On further investigation the example from the API docs doesn't return a metadata field either. So this is what I think might be happening
I'm not uploading the file chunks correctly and the metadata field isn't required for completing the upload.
The API has a bug in it which prevents it from returning the metadata field when registering a multipart upload.
Figured it out, when using the slice method to break your file up into chunks it needs to be file.slice(firstByte, lastByte + 1)
It also seems that the metadata value from the register upload request isn't need to complete the upload.

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>>'
}

Logic App workflow creating or updating documents in CosmosDB fails with conflict

I'm in the process of creating a Logic App which should copy all documents from specific containers in the database to a different database and its corresponding collections.
For this, I've created a workflow which retrieves all documents, loops through them and tries to do a Create or Update document on the target location.
As you can see on the image, this looks fairly straightforward.
I've specified the PartitionKey in the header and Upsert is set to true, so if a document already exists it'll be updated, otherwise created.
Originally, the body was filled with #items('[blurred]_-_For_each_document').
However, I got an error stating there was a conflict on the id.
I've also tried to remove all 'system' properties like so:
#removeProperty(removeProperty(removeProperty(removeProperty(removeProperty(items('[blurred]_-_For_each_document'), 'id'), '_rid'), '_self'), '_ts'), '_etag')
but it appears not having an id in place isn't valid, so now I've got this as I'm only interested in having the contents of the 'actual' document:
#removeProperty(removeProperty(removeProperty(removeProperty(items('[blurred]_-_For_each_document'), '_rid'), '_self'), '_ts'), '_etag')
This still fails.
The raw input looks a bit like this:
{
"method": "post",
"headers": {
"x-ms-documentdb-raw-partitionkey": "1050",
"x-ms-documentdb-is-upsert": "True"
},
"path": "/dbs/[myDatabase]/colls/[myCollection]/docs",
"host": {
"connection": {
"name": "/subscriptions/[subscriptionGuid]/resourceGroups/[resourcegroup]/providers/Microsoft.Web/connections/[connectionName]"
}
},
"body": {
"id": "2faee185-4a51-4797-bff9-3ce23a603690",
"MyPartitionKeyNumber": 1050,
"SomeValue": false,
}
}
With the following response:
{
"code": "Conflict",
"message": "Entity with the specified id already exists in the system., ... ResourceType: Document, OperationType: Upsert ..."
}
I know for a fact, the id doesn't exist, but changed the step to do a PUT anyway.
{
"method": "put",
"headers": {
"x-ms-documentdb-raw-partitionkey": "1050",
"x-ms-documentdb-is-upsert": "True"
},
"path": "/dbs/[myDatabase]/colls/[myCollection]/docs",
"host": {
"connection": {
"name": "/subscriptions/[subscriptionGuid]/resourceGroups/[resourcegroup]/providers/Microsoft.Web/connections/[connectionName]"
}
},
"body": {
"id": "2faee185-4a51-4797-bff9-3ce23a603690",
"MyPartitionKeyNumber": 1050,
"SomeValue": false,
}
}
With a response I'm expecting to see:
{
"statusCode": 404,
"message": "Resource not found"
}
I've also tried to do a Delete document before running the Create or Update document step, but got the same error(s).
There's some post here on Stack Overflow stating the x-ms-documentdb-raw-partitionkey should be x-ms-documentdb-partitionkey (without the raw-part), but doing so results in the following error message:
PartitionKey extracted from document doesn't match the one specified in the header
For completeness sake, these are the relevant steps of my workflow:
"[blurred]_-_Get_all_documents": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['documentdb_3']['connectionId']"
}
},
"method": "get",
"path": "/v2/dbs/#{encodeURIComponent('myDatabase')}/colls/#{encodeURIComponent(items('[blurred]_-_For_each_collection'))}/docs"
},
"runAfter": {}
},
"[blurred]_-_For_each_document": {
"type": "Foreach",
"foreach": "#body('[blurred]_-_Get_all_documents')?['value']",
"actions": {
"[blurred]_-_Create_or_Update_document_on_blurred2": {
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['documentdb_4']['connectionId']"
}
},
"method": "post",
"body": "#removeProperty(removeProperty(removeProperty(removeProperty(items('[blurred]_-_For_each_document'), '_rid'), '_self'), '_ts'), '_etag')",
"headers": {
"x-ms-documentdb-raw-partitionkey": "#{items('[blurred]_-_For_each_document')['MyPartitionKeyNumber']}",
"x-ms-documentdb-is-upsert": true
},
"path": "/dbs/#{encodeURIComponent('myDatabase')}/colls/#{encodeURIComponent(items('[blurred]_-_For_each_collection'))}/docs"
},
"runAfter": {}
}
},
"runAfter": {
"[blurred]_-_Get_all_documents": [
"Succeeded"
]
}
}

Basic Auth header not sent (Swagger)

I have a basic auth secured API but after filling in the authentication credentials, it does not apply to request header. I saw"ERROR Server not found or an error occurred " at swagger editor and "401 Unauthorized" on fiddler.
User Name and Pwd : odata and qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=
Here is my swagger json
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Basic Auth Example",
"description": "An example for how to use Basic Auth with Swagger.\nServer code is available [here](http://navm3.cloudapp.net:90/nav/odata). It's running on NAVM3.\n\n**You can use below User Name and Password for test.**\n* User Name: `ODATA`\n* Password: `qtkr47PTM3pmzLyEHNrW4DXhhgyjMfM3CKUZfXdn0tk=`\n"
},
"host": "navm3.cloudapp.net:90",
"basePath": "/nav/odata",
"schemes": [
"http"
],
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
}
},
"paths": {
"/": {
"get": {
"security": [
{
"basicAuth": []
}
],
"responses": {
"200": {
"description": "Will send `Authenticated` if authentication is succesful, otherwise it will send `Unauthorized`"
}
}
}
}
}
}
i had the same problem, but the problem was in nodeJS back-end.
If you are using NodeJS, probably the problem it is with CORS. You should enable CORS in NodeJS with Express and everything will work.
To enable the CORS in nodeJS you can add the below code, before of the routes.
var app = express();
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, UPDATE, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
next();
});
try to replace the following part:
"securityDefinitions": {
"basicAuth": {
"type": "basic",
"description": "HTTP Basic Authentication. Works over `HTTP` and `HTTPS`"
}
},
with the following
"securityDefinitions": {
"basicAuth": {
"type": "http",
"scheme": "basic"
}
},
keeping the rest as is
here is the reference https://swagger.io/docs/specification/authentication/basic-authentication/

Resources