Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected end-of-input : expected close marker for Object error when trying to send a curl post request in a for loop

Tags:

post

bash

curl

I'm relatively new to bash scripts so forgive me if this is a stupid question. Here is my simple bash script. It is written to send a POST request to a REST API repeatedly. I have set up some alerts to trigger when I have reached a certain threshold of these messages.

for i in {0..600};
do
    curl -X POST -d '{"rsID":{"action":"RECORDING_REQUESTED","ccid":"9999","rsId":"1c047ce2-8870-3072-852c-deae92a89105","chnnlId":"7438caaf-69bd-d76e-8091-3e5f60e57ad7","canonId":"1bb750d2-7b2a-2792-e21b-cdd8e41e6540","srsId":"","xtId":"SH009513260000","schDurSec":"1800","schStrtMillisecs":1539287671000,"schEndMillisecs":1539289471000,"count":40000}' -H "Content-Type:application/json" http://random-site/api/v1/proxy/folders/dvr-scheduler/services/https:dispatch-1-0-5:443/service/addSchedulerEvent;
    echo sent query $i;
    sleep 1;
done

I get this error in the terminal every time

Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@24077193; line: 1, column: 1])
 at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@24077193; line: 1, column: 663]sent query 0
Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@44d2b5af; line: 1, column: 1])
 at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@44d2b5af; line: 1, column: 663]sent query 1
Unexpected end-of-input: expected close marker for Object (start marker at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@f2b601e; line: 1, column: 1])
 at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@f2b601e; line: 1, column: 663]sent query 2

Anybody have an idea on what I am doing wrong?

EDIT: note that schDurSec is a String, while schStrtMillisecs, schEndMillisecs and count are integers.

like image 971
Jvalant Dave Avatar asked Dec 25 '18 14:12

Jvalant Dave


1 Answers

A closing curly brace is missing in your data:

'{"rsID":
   {"action":"RECORDING_REQUESTED",
    "ccid":"9999",
    "rsId":"1c047ce2-8870-3072-852c-deae92a89105",
    "chnnlId":"7438caaf-69bd-d76e-8091-3e5f60e57ad7",
    "canonId":"1bb750d2-7b2a-2792-e21b-cdd8e41e6540",
    "srsId":"",
    "xtId":"SH009513260000",
    "schDurSec":"1800",
    "schStrtMillisecs":1539287671000,
    "schEndMillisecs":1539289471000,
    "count":40000
   }
}' # <-- this brace is missing
like image 154
Rene Knop Avatar answered Sep 25 '22 20:09

Rene Knop