I am trying to send project setting to API server with javascript (no node js) here is my code
var project = {
template: 'template.aepx',
composition: 'main',
settings: {
outputModule: 'mine',
outputExt: 'mov',
startFrame: 0,
endFrame: 600
},
assets: [
{
type: 'project',
src: 'http://localhost/nexTest/assets/template.aepx',
name: 'template.aepx'
}, {
type: 'image',
src: 'http://localhost/nexTest/assets/nm.png',
name: 'nm.jpg'
}, {
type: 'image',
src: 'http://localhost/nexTest/assets/2016-aug-deep.jpg',
name: 'background.jpg',
filters: [{
name: 'cover',
params: [1280, 720]
}],
}, {
type: 'audio',
src: 'http://localhost/nexTest/assets/deep_60s.mp3',
name: 'track.mp3'
}, {
type: 'script',
src: 'http://localhost/nexTest/assets/2016-aug-deep.js',
name: 'script.js'
}
]
}
$.ajax({
type: "POST",
url: "http://localhost:3000/projects",
dataType:'json',
form: JSON.stringify(project),
success: function(result){
console.log(result);
},
error: function(error) {
console.log(error);
}
});`
but every time i get 404 from API server, what am i doing wrong ?
hello,
if you didnt change the
let API_URL = 'http://localhost:3000/api/';
the url should be http://localhost:3000/api/projects
try changing it, might help :)
Thanks for the reply, I am able to create projects now but I am still stuck at sending correct data to API.
No matter what request I send to API it always overrides my assets values.
var project = { template: 'template.aepx', composition: 'main', settings: { outputModule: 'mine', outputExt: 'mov', startFrame: 0, endFrame: 600 }, assets: [ { type: 'project', src: 'http://localhost/nexTest/assets/template.aepx', name: 'template.aepx' }, { type: 'image', src: 'http://localhost/nexTest/assets/nm.png', name: 'nm.jpg' }, { type: 'image', src: 'http://localhost/nexTest/assets/2016-aug-deep.jpg', name: 'background.jpg', filters: [{ name: 'cover', params: [1280, 720] }], }, { type: 'audio', src: 'http://localhost/nexTest/assets/deep_60s.mp3', name: 'track.mp3' }, { type: 'script', src: 'http://localhost/nexTest/assets/2016-aug-deep.js', name: 'script.js' } ] }
this is the data which I am trying to send but renderer fails with the result:
Error message: ENOENT: no such file or directory, stat 'F:\programming\nex\temp\rk25cdbbb\result.mp4'
and data in db.json is:
{
"{\"template\":\"template.aepx\",\"composition\":\"main\",\"settings\":{\"outputModule\":\"mine\",\"outputExt\":\"mov\",\"startFrame\":0,\"endFrame\":600},\"assets\":[{\"type\":\"project\",\"src\":\"http://localhost/nexTest/assets/template.aepx\",\"name\":\"template.aepx\"},{\"type\":\"image\",\"src\":\"http://localhost/nexTest/assets/nm.png\",\"name\":\"nm.jpg\"},{\"type\":\"image\",\"src\":\"http://localhost/nexTest/assets/2016-aug-deep.jpg\",\"name\":\"background.jpg\",\"filters\":[{\"name\":\"cover\",\"params\":": {
"1280,720": ""
},
"uid": "Skl3K_b-b",
"state": "failed",
"createdAt": "2017-05-23T08:58:16.359Z",
"updatedAt": "2017-05-23T08:59:10.186Z",
"type": "default",
"assets": [],
"template": "template.aep",
"settings": {
"outputModule": "h264",
"outputExt": "mp4"
},
"composition": "comp1",
"actions": [],
"errorMessage": "ENOENT: no such file or directory, stat 'F:\\programming\\nex\\temp\\Skl3K_b-b\\result.mp4'"
}
my all values changed to some default values. please help.
just noticed, seems like you are sending data via ajax as from/url-encoded
form: JSON.stringify(project),
but try changing it to the raw data:
data: JSON.stringify(project),
Changed request to
var project = {
template: 'template.aepx',
composition: 'main',
settings: {
outputModule: 'mine',
outputExt: 'mov',
startFrame: 0,
endFrame: 600
},
assets: [
{
type: 'project',
src: 'http://localhost/nexTest/assets/template.aepx',
name: 'template.aepx'
}, {
type: 'image',
src: 'http://localhost/nexTest/assets/nm.png',
name: 'nm.jpg'
}, {
type: 'image',
src: 'http://localhost/nexTest/assets/2016-aug-deep.jpg',
name: 'background.jpg',
filters: [{
name: 'cover',
params: [1280, 720]
}],
}, {
type: 'audio',
src: 'http://localhost/nexTest/assets/deep_60s.mp3',
name: 'track.mp3'
}, {
type: 'script',
src: 'http://localhost/nexTest/assets/2016-aug-deep.js',
name: 'script.js'
}
]
}
$.ajax({
type: "POST",
url: "http://localhost:3000/api/projects",
data: JSON.stringify(project),
success: function (result) {
console.log(result);
},
error: function (error) {
console.log(error);
}
});
still same result. I am really confused.
{
"{\"template\":\"template.aepx\",\"composition\":\"main\",\"settings\":{\"outputModule\":\"mine\",\"outputExt\":\"mov\",\"startFrame\":0,\"endFrame\":600},\"assets\":[{\"type\":\"project\",\"src\":\"http://localhost/nexTest/assets/template.aepx\",\"name\":\"template.aepx\"},{\"type\":\"image\",\"src\":\"http://localhost/nexTest/assets/nm.png\",\"name\":\"nm.jpg\"},{\"type\":\"image\",\"src\":\"http://localhost/nexTest/assets/2016-aug-deep.jpg\",\"name\":\"background.jpg\",\"filters\":[{\"name\":\"cover\",\"params\":": {
"1280,720": ""
},
"uid": "B12qTd-bW",
"state": "failed",
"createdAt": "2017-05-23T09:15:00.254Z",
"updatedAt": "2017-05-23T09:15:56.798Z",
"type": "default",
"assets": [],
"template": "template.aep",
"settings": {
"outputModule": "h264",
"outputExt": "mp4"
},
"composition": "comp1",
"actions": [],
"errorMessage": "ENOENT: no such file or directory, stat 'F:\\programming\\nex\\temp\\B12qTd-bW\\result.mp4'"
}
hmm, thats weird
something wrong with project thats arriving to the database
it has string encoding with backslashes, which means it because of JSON.stringify
maybe try making request without it ?
It worked! now all resources are correct as I give them, renderer creates the project folder and copies all files but fails, giving me this error:
Response code 404 (Not Found)
whole project data is
{
"template": "template.aepx",
"composition": "main",
"settings": {
"outputModule": "mine",
"outputExt": "mov",
"startFrame": "0",
"endFrame": "600"
},
"assets": [
{
"type": "project",
"src": "http://localhost/nexTest/assets/template.aepx",
"name": "template.aepx"
},
{
"type": "image",
"src": "http://localhost/nexTest/assets/nm.png",
"name": "nm.jpg"
},
{
"type": "image",
"src": "http://localhost/nexTest/assets/2016-aug-deep.jpg",
"name": "background.jpg",
"filters": [
{
"name": "cover",
"params": [
"1280",
"720"
]
}
]
},
{
"type": "audio",
"src": "http://localhost/nexTest/assets/deep_60s.mp3",
"name": "track.mp3"
},
{
"type": "script",
"src": "http://localhost/nexTest/assets/2016-aug-deep.js",
"name": "script.js"
}
],
"uid": "S1aistbWW",
"state": "failed",
"createdAt": "2017-05-23T10:15:01.152Z",
"updatedAt": "2017-05-23T10:15:35.438Z",
"type": "default",
"actions": [],
"errorMessage": "Response code 404 (Not Found)"
}
I have checked all assets they present on web server and I cannot figure out this error.
hm, this should be related to either image or mp3 or js or project file downloading (assets)
as far as i remember there can't be other possible places to make web request and receive 404
I looked properly at all the resources on my web server and in temp project folder after it tries to render the project. All files are copied except the template file and project fails to render giving error:
making request for projects...
looking for suitable projects...
[SkT12TfWb] setting up project...[SkT12TfWb] downloading assets...
Error message: Response code 404 (Not Found)
EDIT:
I figured out the reason I was getting 404, My IIS server was not configured to serve aepx files, I added a mime type in config now I am able to download all resources.
But now the problem is in filtering images, the error I am getting is:
Error message: w and h must be numbers
I believe this is JIMP related issue. Also in db.json, the params I send in filter option gets converted into a string.
{
"type": "image",
"src": "http://localhost/nexTest/assets/2016-aug-deep.jpg",
"name": "background.jpg",
"filters": [
{
"name": "cover",
"params": [
"1280",
"720"
]
}
]
}
This might be causing the JIMP to fail.
[ "1280", "720" ]
try making them numbers
[ 1280, 720 ]
this should help
also this filters field is optional, so you can just skip it, if you want
@Inlife I am running into the same issue, I need the filter params, and it automatically converts them to string on the node server. do you know how to fix that, instead of skipping that issue?
these parameters are required to be numbers
what is automatically converting them ?
which node server ?
I am making an ajax POST request to the API Server
ItemJSON = {
'template': 'project.aepx',
'composition': 'main',
'settings': {
'outputModule': 'h264',
'outputExt': 'mov',
'startFrame': 0,
'endFrame': 1800
},
'assets': [
{
'type': 'project',
'src': 'http://localhost/assets/nm05ae12.aepx',
'name': 'project.aepx'
},
{
'type': 'image',
'src': 'http://localhost/video/uploads/' + dir + '/' + file_name,
'name': 'background.jpg',
'filters': [
{
'name': 'cover',
"params": [1080 ,1080]
}
]
},
{
'type': 'audio',
'src': 'http://localhost/assets/deep_60s.mp3',
'name': 'track.mp3'
},
{
'type': 'script',
'src': 'http://localhost/video/uploads/' + dir + '/data.js',
'name': 'data.js'
}
]
} ;
$.ajax({
async: true,
type: "POST",
dataType:'application/json',
url: "http://localhost:3000/api/projects",
data: ItemJSON,
});
then it is getting saved in db.json, but the filter params are converted to strings
"filters": [
{
"name": "cover",
"params": [
"1080",
"1080"
]
}
]
not sure why stuff like this is happening
integer type params should be kept integers even after JSON.stringify call
i never had such issue tho, which possibly means that problem is inside the ajax call
maybe try some other way of calling it ?
i think it has something to do with the client that sends the json as string to the node server. do you know how to parse it in node/express?
i converted the json into a string on client and sent it to node. now i am getting the backslashes. all i need to to is to convert the string (with backslahses) to json in node/express... any idea?