mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
feat(LinkedIn Node): Upgrade LinkedIn API version (#9307)
This commit is contained in:
parent
ece60449b9
commit
3860077f81
|
@ -37,7 +37,7 @@ export async function linkedInApiRequest(
|
||||||
headers: {
|
headers: {
|
||||||
Accept: 'application/json',
|
Accept: 'application/json',
|
||||||
'X-Restli-Protocol-Version': '2.0.0',
|
'X-Restli-Protocol-Version': '2.0.0',
|
||||||
'LinkedIn-Version': '202304',
|
'LinkedIn-Version': '202404',
|
||||||
},
|
},
|
||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
|
@ -52,6 +52,9 @@ export async function linkedInApiRequest(
|
||||||
if (binary) {
|
if (binary) {
|
||||||
delete options.json;
|
delete options.json;
|
||||||
options.encoding = null;
|
options.encoding = null;
|
||||||
|
if (Object.keys(_headers as object).length > 0) {
|
||||||
|
Object.assign(options.headers as object, _headers);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(body as IDataObject).length === 0) {
|
if (Object.keys(body as IDataObject).length === 0) {
|
||||||
|
|
|
@ -172,11 +172,22 @@ export class LinkedIn implements INodeType {
|
||||||
);
|
);
|
||||||
|
|
||||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
||||||
this.helpers.assertBinaryData(i, binaryPropertyName);
|
const imageMetadata = this.helpers.assertBinaryData(i, binaryPropertyName);
|
||||||
|
|
||||||
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
||||||
const { uploadUrl, image } = registerObject.value;
|
const { uploadUrl, image } = registerObject.value;
|
||||||
await linkedInApiRequest.call(this, 'POST', uploadUrl as string, buffer, true);
|
|
||||||
|
const headers = {};
|
||||||
|
Object.assign(headers, { 'Content-Type': imageMetadata.mimeType });
|
||||||
|
|
||||||
|
await linkedInApiRequest.call(
|
||||||
|
this,
|
||||||
|
'POST',
|
||||||
|
uploadUrl as string,
|
||||||
|
buffer,
|
||||||
|
true,
|
||||||
|
headers,
|
||||||
|
);
|
||||||
|
|
||||||
const imageBody = {
|
const imageBody = {
|
||||||
content: {
|
content: {
|
||||||
|
@ -225,11 +236,22 @@ export class LinkedIn implements INodeType {
|
||||||
);
|
);
|
||||||
|
|
||||||
const binaryPropertyName = additionalFields.thumbnailBinaryPropertyName as string;
|
const binaryPropertyName = additionalFields.thumbnailBinaryPropertyName as string;
|
||||||
this.helpers.assertBinaryData(i, binaryPropertyName);
|
const imageMetadata = this.helpers.assertBinaryData(i, binaryPropertyName);
|
||||||
|
|
||||||
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
||||||
const { uploadUrl, image } = registerObject.value;
|
const { uploadUrl, image } = registerObject.value;
|
||||||
await linkedInApiRequest.call(this, 'POST', uploadUrl as string, buffer, true);
|
|
||||||
|
const headers = {};
|
||||||
|
Object.assign(headers, { 'Content-Type': imageMetadata.mimeType });
|
||||||
|
|
||||||
|
await linkedInApiRequest.call(
|
||||||
|
this,
|
||||||
|
'POST',
|
||||||
|
uploadUrl as string,
|
||||||
|
buffer,
|
||||||
|
true,
|
||||||
|
headers,
|
||||||
|
);
|
||||||
Object.assign(articleBody.content.article, { thumbnail: image });
|
Object.assign(articleBody.content.article, { thumbnail: image });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue