Cronicle icon indicating copy to clipboard operation
Cronicle copied to clipboard

400 Bad request on api call

Open streightedge opened this issue 2 years ago • 5 comments

Hi,

we have encountered a strange issue on api calls. The same configuration works on one and on another we get Bad request 400 error.

Api calls are:

curl -X POST -H "Content-Type: application/json" -H "X-API-Key: " -d @run.json http://ip1:3012/api/app/run_event/v1 cat run.json {         "id": "jobid1" }

curl -X POST -H "Content-Type: application/json" -H "X-API-Key: " -d @run.json http://ip2:3012/api/app/run_event/v1 cat run.json {         "id": "jobid2" }

On the one that is not working i have tried many different key's and i get always the same 400.

I put the /api/app/run_job/v1 in the browser of the one that its not working and i get correct response: {"code":1,"description":"Unsupported API: app/api_run_job"}

Any suggestions are much appreciated.

streightedge avatar Apr 19 '23 08:04 streightedge

Is your host "ip2" a primary or backup server? You can start jobs only on the primary system.

mcfetz avatar Apr 19 '23 10:04 mcfetz

Both are in same configuration. The api call is from worker that sends the request to the master (primary) server.

streightedge avatar Apr 19 '23 10:04 streightedge

Check the Cronicle logs, especially the WebServer.log. It should have more information on why it is sending back a HTTP 400.

jhuckaby avatar Apr 20 '23 02:04 jhuckaby

This is log output:

1681889738.394][2023-04-19 02:35:38][][1036][WebServer][error][400][Error processing data from: 10.227.97.14: /api/app/run_event/v1: Failed to parse JSON: SyntaxError: Unexpected token in JSON at position 1][{"id":"r364","ips":[""],"uri":"/api/app/run_event/v1","headers":{"user-agent":"curl/7.29.0","host":"10.227.97.6:3012","accept":"/","content-type":"application/json","x-api-key":"dbc32c569bb4273ff963040549436fc5","content-length":"36"},"body":"{ "id": "elgnfacue07""}"}] [1681889738.394][2023-04-19 02:35:38][][1036][WebServer][debug][9][Sending HTTP response: 400 Bad Request][{"Access-Control-Allow-Origin":"*","Server":"Cronicle 1.0","Content-Length":15}]

is this an issue with the id?

run config: cat run.json {         "id": "elgnfacue07" }

and the same id is in the cronicle portal.

streightedge avatar Apr 21 '23 14:04 streightedge

I don't know what to tell you, @streightedge. It works fine for me:

jhuckaby@joework temp $ cat run.json 
{
	"id": "eilhcggvv01"
}
jhuckaby@joework temp $ 
jhuckaby@joework temp $ curl -X POST -H "Content-Type: application/json" -H "X-API-Key: b5df700456c0cb60c9ef07f867d35624" 
-d @run.json http://cronicle.dev.myserver.com:3012/api/app/run_event/v1
{"code":0,"ids":["jlgqresw105"]}
jhuckaby@joework temp $ 

That successfully launched my job.

screenshot

jhuckaby avatar Apr 21 '23 16:04 jhuckaby