Copy link to clipboard
Copied
I'm trying to dynamically change the image file in a .pds layer. Using the Photoshop api. For some reason i'm getting the error type 'MethodNotAllowed'.
import fetch from 'node-fetch';
// Configura las URLs usando ngrok
const PSD_FILE_URL = 'https://ccc2-190-153-141-181.ngrok-free.app/your-psd-file.psd';
const OUTPUT_URL = 'https://www.dropbox.com/scl/fi/jt5xfao0sptp77lcrnqvw/output.psd'
export async function replaceSmartObject(newContentUrl, token, apiKey) {
const data = {
"inputs": [
{
"storage": "external",
"href": PSD_FILE_URL
}
],
"options": {
"layers": [
{
"name": "layer_to_change",
"input": {
"storage": "external",
"href": newContentUrl,
},
}
]
},
"outputs": [
{
"storage": "dropbox",
"href": OUTPUT_URL,
"type": "image/vnd.adobe.photoshop",
"overwrite": true
}
]
};
const response = await fetch('https://image.adobe.io/pie/psdService/smartObject', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
'x-api-key': apiKey
},
body: JSON.stringify(data)
});
if (!response.ok) {
const error = await response.json();
throw new Error(`Error: ${error.message}`);
}
return response.json();
}
PSD original file and the input image file are in my local machine. I'm having problems when running the script. For some reason I'm getting this error:
Operation status: {
jobId: '9cccaacb-23a2-4f18-aea2-9038ee223c6c',
outputs: [
{
input: 'https://ccc2-190-153-141-181.ngrok-free.app/your-psd-file.psd',
status: 'failed',
created: '2024-06-16T08:40:46.282Z',
modified: '2024-06-16T08:40:49.256Z',
errors: [Object]
}
],
_links: {
self: {
href: 'https://image.adobe.io/pie/psdService/status/9cccaacb-23a2-4f18-aea2-9038ee223c6c'
}
}
}
Error details: {
code: 405,
title: 'Internal Service Error',
type: 'MethodNotAllowed'
}
^C
tomasleblanc@Tomass-MacBook-Pro MerchVisor % node server.js
Server running on http://localhost:3000
Esperando 5 segundos antes de verificar el estado...
Operation status: {
jobId: 'ad009007-25df-415f-992d-18f0ec54c92a',
outputs: [
{
input: 'https://ccc2-190-153-141-181.ngrok-free.app/your-psd-file.psd',
status: 'failed',
created: '2024-06-16T08:47:21.38Z',
modified: '2024-06-16T08:47:23.835Z',
errors: [Object]
}
],
_links: {
self: {
href: 'https://image.adobe.io/pie/psdService/status/ad009007-25df-415f-992d-18f0ec54c92a'
}
}
}
Error details: {
code: 405,
title: 'Internal Service Error',
type: 'MethodNotAllowed'
}
Have something to add?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more