n8n-nodes-pinterest 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,8 @@ function buildCommonHeaders(csrf) {
12
12
  'x-pinterest-pws-handler': 'www/[username].js',
13
13
  'x-CSRFToken': csrf,
14
14
  'Accept-Language': 'en-US,en;q=0.9',
15
+ Accept: 'application/json, text/plain, */*',
16
+ 'X-Requested-With': 'XMLHttpRequest',
15
17
  };
16
18
  }
17
19
  function buildCookieHeader(sess, csrf) {
@@ -353,15 +355,14 @@ class PinterestCookie {
353
355
  board_id: boardId,
354
356
  field_set_key: 'create_success',
355
357
  skip_pin_create_log: true,
356
- description,
357
- alt_text: additionalFields.alt_text || '',
358
+ ...(description ? { description } : {}),
359
+ ...(additionalFields.alt_text ? { alt_text: additionalFields.alt_text } : {}),
358
360
  ...(attachLink && additionalFields.link ? { link: additionalFields.link } : {}),
359
- title,
361
+ ...(title ? { title } : {}),
360
362
  image_url: imageUrl,
361
363
  method: 'uploaded',
362
364
  upload_metric: { source: 'pinner_upload_standalone' },
363
- user_mention_tags: [],
364
- no_fetch_context_on_resource: false,
365
+ // omit user_mention_tags/no_fetch_context for stricter compatibility
365
366
  },
366
367
  context: {},
367
368
  };
@@ -374,7 +375,7 @@ class PinterestCookie {
374
375
  source_url: '/pin-builder/',
375
376
  data: JSON.stringify(payload),
376
377
  },
377
- headers: { ...baseHeaders, Cookie: cookieHeader, Accept: '*/*', Referer: `${base}/pin-builder/`, Origin: base },
378
+ headers: { ...baseHeaders, Cookie: cookieHeader, Referer: `${base}/pin-builder/`, Origin: base },
378
379
  proxy: proxy || undefined,
379
380
  // Get body even on 4xx
380
381
  simple: false,
@@ -393,17 +394,37 @@ class PinterestCookie {
393
394
  const msgDetail = ((_b = createdRes.error) === null || _b === void 0 ? void 0 : _b.message_detail) || '';
394
395
  return { ok: Boolean(id), id, msg: String(msg || msgDetail || ''), body };
395
396
  };
396
- // First attempt (with link if provided and attachLink=true)
397
- let result = await attemptCreate(sendData);
398
- // If blocked due to destination site, retry without link
399
- if (!result.ok && /doesn\'t allow you to save Pins|does not allow you to save Pins/i.test(result.msg)) {
400
- const withoutLink = JSON.parse(JSON.stringify(sendData));
401
- if (withoutLink.options)
402
- delete withoutLink.options.link;
403
- result = await attemptCreate(withoutLink);
397
+ // Try strategies progressively to avoid generic "Invalid parameters"
398
+ const strategies = [];
399
+ // 1) As built
400
+ strategies.push(JSON.parse(JSON.stringify(sendData)));
401
+ // 2) Without link
402
+ const s2 = JSON.parse(JSON.stringify(sendData));
403
+ if (s2.options)
404
+ delete s2.options.link;
405
+ strategies.push(s2);
406
+ // 3) Minimal fields only
407
+ strategies.push({
408
+ options: {
409
+ board_id: boardId,
410
+ field_set_key: 'create_success',
411
+ image_url: imageUrl,
412
+ method: 'uploaded',
413
+ },
414
+ context: {},
415
+ });
416
+ let result = { ok: false };
417
+ for (const strat of strategies) {
418
+ result = await attemptCreate(strat);
419
+ if (result.ok)
420
+ break;
421
+ // If explicit site-block message, skip to minimal next
422
+ if (/doesn\'t allow you to save Pins|does not allow you to save Pins/i.test(result.msg || ''))
423
+ continue;
404
424
  }
405
425
  if (!result.ok) {
406
- throw new Error(result.msg || 'Create failed');
426
+ // surface full server message for troubleshooting
427
+ throw new Error(result.msg || result.body || 'Create failed');
407
428
  }
408
429
  returnData.push({ json: { id: result.id, link: `https://www.pinterest.com/pin/${result.id}` } });
409
430
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-pinterest",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "n8n community nodes for Pinterest v5 API (list boards, create pins)",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",