I'm running a cURL shell script from an (indesign) extendscript jsx-file.
This works well for simple queries, but in the command below you can see that I'm having quite some quotation nesting, which seem to be making the command fail! It's not throwing any errors, but the Wordpress-Post is not being changed!
var command = 'do shell script "curl -X PUT -H \'Content-Type: application/json\' -d \' { \'title\': \'Blub\', \'content_raw\': \'Updated post content\' } \' -u username:password http://website.com/wp-json/wp/v2/cpt/12/"';
var response = app.doScript(command, ScriptLanguage.APPLESCRIPT_LANGUAGE);
When I write it like this it throws an error, because of false quotations:
var command = 'do shell script "curl -X PUT -H \"Content-Type: application/json\" -d \" { \"title\": \"Blub\", \"content_raw\": \"Updated post content\" } \" -u admin:password http://seebook.dev/wp-json/wp/v2/calendar/12/"';
When I run the command directly in the terminal, it works...
curl -X PUT -H "Content-Type: application/json" -d " { \"title\": \"Updates Title\", \"content_raw\": \"Updated post content\" } " -u username:password http://website.com/wp-json/wp/v2/cpt/12/
So does this version:
var command = 'do shell script "curl -X PUT -H \"Content-Type: application/json\" -d \" { \'title\': \'Blub\', \'content_raw\': \'Updated post content\' } \" -u username:password http://website.com/wp-json/wp/v2/cpt/12/"';
How can I write the query, so that it works?
I guess that's quite a noob question, but I've never had such a situation before...
All the best, Lukas