error while importing data by curl comand

277 views Asked by At

Hi I am trying to import data using API token to my REDCap projet.

This is my curl script

TOKEN="xyz"
SERVICE="https://cri-datacap.org/api/"
curl -F token=${TOKEN} -F overwriteBehavior=normal -F content=record -F  type=flat -F format=csv -F data="</opt/temp//my.csv" ${SERVICE}

 here is my.csv

=====================================

record_id,seat_id_seq,address,price,email,tickets1_complete
123,aaa,aaa,aaa,aaa,2

and It is importing data perfectly fine without any error.

Now I don't want to send data by the .csv file. I want to use data directly in my script and import it in the json format. So I have modified the script :

TOKEN="xyz"
SERVICE="https://cri-datacap.org/api/"    
loaddata={"record_id":222,"seat_id_seq":"bbb","address":"bbb","price":"bbb","email":"bbb","tickets1_complete":2}
curl -F token=${TOKEN} -F overwriteBehavior=normal -F content=record -F type=flat -F format=json -F data=${loaddata} ${SERVICE}

But now It is throwing error:

{"error":"The data being imported is not formatted correctly"}
0

There are 0 answers