LinkedIn 营销 API- 无效的完整 multipartUpload 请求

LinkedIn Marketing API- Invalid complete multipartUpload request

我正在尝试根据 the marketing API documentation 将视频上传到 Linkedin API。到目前为止,我已经完成了以下工作:

不幸的是,我的请求失败了:

'com.linkedin.vector.utils.logic.LogicLayerInvalidException: Invalid complete multipartUpload request ...(stringified payload)'

请求的唯一部分 body 我没有从给出的示例中添加的是“元数据”字段 - 文档中没有任何内容来解释它是什么或它从哪里生成。我假设这就是所缺少的。谁能给我指出正确的方向?

相关请求代码如下:

    // Loop over chunked download URLs and upload segments of S3 file.
    for(let i = 0, l = uploadDetails.partUploadRequests.length; i < l; i++) {
        const item: PartUploadRequest = uploadDetails.partUploadRequests[i];
        const partialParams: GetObjectRequest = { Bucket: video.dynamoData.mp4Bucket, Key: video.dynamoData.mp4Outputs[0], Range: `bytes=${item.byteRange.firstByte}-${item.byteRange.lastByte}` };
        console.log(`Requesting bytes ${item.byteRange.firstByte}-${item.byteRange.lastByte}`);
        const s3PartialObject = await s3Client.getObject(partialParams).promise();
        const response = await axios.put(item.url, s3PartialObject.Body, {
            headers: {
                ...item.headers
            }
        });

        const { status, headers } = response;
        responses.push({
            headers: {
                ETag: headers.etag
            },
            httpStatusCode: status
        });
    };

    // Send all chunk responses off and confirm video upload
    const finaliseVideoPayload: LinkedinFinaliseVideoPostRequest = {
        completeMultipartUploadRequest: {
            mediaArtifact: registerVideoRequest.value.mediaArtifact,
            partUploadResponses: responses
        }
    };

    console.log(`Fetched all parts, readying finalise request with ${finaliseVideoPayload.completeMultipartUploadRequest.partUploadResponses.length} parts.`);

    const json = await axios.post('https://api.linkedin.com/v2/assets?action=completeMultiPartUpload', finaliseVideoPayload, {
        headers: {
            'X-RestLi-Protocol-Version': '2.0.0',
            'Authorization': 'Bearer ' + channel.token,
            'Host': 'api.linkedin.com'
        }
    });

谢谢

我想这已经解决了。以防万一。

registerApi 中有一个字段 'metadata' 用于分段上传。这是在现场。

uploadMechanism["com.linkedin.digitalmedia.uploading.MultipartUpload"].metadata

显然,这是 completeMultipart 所必需的 api。

因此数据将是

completeMultipartUploadRequest: {
            mediaArtifact: registerVideoRequest.value.mediaArtifact,
            metadata: registerVideoRequest.value.uploadMechanism["com.linkedin.digitalmedia.uploading.MultipartUpload"].metadata,
            partUploadResponses: responses
        }

我花了一天时间才弄清楚没有值(空字符串)的字段是必需的。也许是一个错误。 希望这能解决问题。