1

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"}
Mohammad Shahbaz
  • 403
  • 8
  • 28
  • Never, ever show your token! – pap Mar 30 '20 at 22:33
  • This typically results from a mismatch between your csv and the REDCap project's structure. See the "Writing" section in the trouble-shooting document: https://ouhscbbmc.github.io/REDCapR/articles/TroubleshootingApiCalls.html – wibeasley Nov 07 '21 at 19:44
  • that token was expired long ago, but i still edtied – Mohammad Shahbaz Mar 17 '22 at 20:00
  • @mohammad-shahbaz Please do not edit 5 year old questions, if the question will not get better after the edit... – Luuk Mar 17 '22 at 20:02

0 Answers0