Re: [Dhis2-users] [Dhis2-devs] Uploading CSV data file with curl
I agree with Vladimer, I think it would even be a good idea to have a cheatsheet where all API endpoints can be readily found (with usage format) rather than having to srach through the docs every time. I know for old users, it might be no issue but how about the new users. I will be willing to create the cheatsheet if anyone can provide valid and complete information on the endpoints. On Wed, Jul 4, 2018 at 2:31 PM Vladimer Shioshvili wrote: > Thanks Knut - but documentation doesn't specify the API endpoint, or how > you specify the metadata object type (it is a drop-down in import/export > app). > > On Wed, Jul 4, 2018, 16:37 Knut Staring wrote: > >> It is possible: >> https://docs.dhis2.org/master/en/developer/html/webapi_csv_metadata_import.html >> >> Knut >> >> On Wed, Jul 4, 2018 at 2:31 PM Vladimer Shioshvili >> wrote: >> >>> Leke, >>> >>> While it's good to use --data-binary, in your curl calls in both >>> examples, you are missing -H switch in front of the content type (look at >>> the example Knut provided), which makes it default to >>> application/x-www-form-urlencoded. Make sure you include -H; >>> >>> Knut (and others), Leke's original question mentioned dataElements, and >>> it got me looking too, and i noticed that while the documentation talks >>> about columns for the metadata csv content, it never gives the API >>> endpoints for importing metadata using CSV. Is that even possible? There >>> are classes to handle it in the code, and I know import/export app does it >>> (i've used it), but what about API? >>> >>> Vlad >>> >>> On Wed, Jul 4, 2018 at 5:45 AM Knut Staring wrote: >>> Hi Leke, according to the link I sent you have to use --data-binary as in this request: curl --data-binary @datavalueset.csv "https://play.dhis2.org/demo/24/api/dataValueSets; -H "Content-Type:application/csv" -u admin:district -v Knut On Wed, Jul 4, 2018 at 11:35 AM Olaleke Seweje wrote: > Thanks Knut, I tried with dataValueSets and got exactly the same > error. Below is what my curl request looked like. > > curl -d @file.name.csv "http://myHostName/api/26/dataValueSets; -X > POST "Content-Type: application/csv" -u username:password > > > *The result* > > > {"httpStatus":"Unsupported Media > Type","httpStatusCode":415,"status":"ERROR","message":"Content type > 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not > resolve host: Content-Type > > > Please what do I need to look into again? > > Is the format of the curl request correct? > > Is there something I need to set on my DHIS instance to make it > support such operations? > > > > On Wed, Jul 4, 2018 at 8:21 AM Knut Staring wrote: > >> Hi Leke, are you sending METADATA or DATA VALUES? >> >> If the latter, you need to use dataValueSets: >> >> https://docs.dhis2.org/master/en/developer/html/webapi_data_values.html#webapi_sending_data_values >> >> Knut >> >> On Wed, Jul 4, 2018 at 5:58 AM Olaleke Seweje < >> sewejeolal...@gmail.com> wrote: >> >>> Hi all, >>> >>> I am trying to upload data via CURL as specified in the dev docs - >>> 1.9.2. Creating >>> and updating objects. My request is as follows: >>> >>> >>> curl -d @file._name.csv "http://myHostName/api/26/dataElements; -X >>> POST "Content-Type: application/csv" -u username:password >>> >>> >>> >>> *The response I got was * >>> >>> >>> {"httpStatus":"Unsupported Media >>> Type","httpStatusCode":415,"status":"ERROR","message":"Content type >>> 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not >>> resolve host: Content-Type >>> >>> I have tried content type text/csv as well but got similar results. >>> >>> My questions >>> 1. Is my endpoint http://myHostName/api/26/dataElements the correct >>> one for uploading data values via API? >>> >>> 2. Is the request format correct? >>> >>> 3. Is there something I need to set on my DHIS instance to make it >>> support such operations? >>> >>> Thanks for your help. >>> >>> >>> -- >>> Regards, >>> Leke Seweje >>> ___ >>> Mailing list: https://launchpad.net/~dhis2-devs >>> Post to : dhis2-d...@lists.launchpad.net >>> Unsubscribe : https://launchpad.net/~dhis2-devs >>> More help : https://help.launchpad.net/ListHelp >>> >> >> >> -- >> Knut Staring >> >> Department of Information, Evidence and Research >> World Health Organization, Geneva, Switzerland >> Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 >> Skype: knutstar >> > > > -- > Regards, > Leke Seweje > -- Knut Staring
Re: [Dhis2-users] [Dhis2-devs] Uploading CSV data file with curl
Thanks Knut - but documentation doesn't specify the API endpoint, or how you specify the metadata object type (it is a drop-down in import/export app). On Wed, Jul 4, 2018, 16:37 Knut Staring wrote: > It is possible: > https://docs.dhis2.org/master/en/developer/html/webapi_csv_metadata_import.html > > Knut > > On Wed, Jul 4, 2018 at 2:31 PM Vladimer Shioshvili > wrote: > >> Leke, >> >> While it's good to use --data-binary, in your curl calls in both >> examples, you are missing -H switch in front of the content type (look at >> the example Knut provided), which makes it default to >> application/x-www-form-urlencoded. Make sure you include -H; >> >> Knut (and others), Leke's original question mentioned dataElements, and >> it got me looking too, and i noticed that while the documentation talks >> about columns for the metadata csv content, it never gives the API >> endpoints for importing metadata using CSV. Is that even possible? There >> are classes to handle it in the code, and I know import/export app does it >> (i've used it), but what about API? >> >> Vlad >> >> On Wed, Jul 4, 2018 at 5:45 AM Knut Staring wrote: >> >>> Hi Leke, according to the link I sent you have to use --data-binary as >>> in this request: >>> >>> curl --data-binary @datavalueset.csv >>> "https://play.dhis2.org/demo/24/api/dataValueSets; >>> -H "Content-Type:application/csv" -u admin:district -v >>> >>> Knut >>> >>> On Wed, Jul 4, 2018 at 11:35 AM Olaleke Seweje >>> wrote: >>> Thanks Knut, I tried with dataValueSets and got exactly the same error. Below is what my curl request looked like. curl -d @file.name.csv "http://myHostName/api/26/dataValueSets; -X POST "Content-Type: application/csv" -u username:password *The result* {"httpStatus":"Unsupported Media Type","httpStatusCode":415,"status":"ERROR","message":"Content type 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not resolve host: Content-Type Please what do I need to look into again? Is the format of the curl request correct? Is there something I need to set on my DHIS instance to make it support such operations? On Wed, Jul 4, 2018 at 8:21 AM Knut Staring wrote: > Hi Leke, are you sending METADATA or DATA VALUES? > > If the latter, you need to use dataValueSets: > > https://docs.dhis2.org/master/en/developer/html/webapi_data_values.html#webapi_sending_data_values > > Knut > > On Wed, Jul 4, 2018 at 5:58 AM Olaleke Seweje > wrote: > >> Hi all, >> >> I am trying to upload data via CURL as specified in the dev docs - >> 1.9.2. Creating >> and updating objects. My request is as follows: >> >> >> curl -d @file._name.csv "http://myHostName/api/26/dataElements; -X >> POST "Content-Type: application/csv" -u username:password >> >> >> >> *The response I got was * >> >> >> {"httpStatus":"Unsupported Media >> Type","httpStatusCode":415,"status":"ERROR","message":"Content type >> 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not >> resolve host: Content-Type >> >> I have tried content type text/csv as well but got similar results. >> >> My questions >> 1. Is my endpoint http://myHostName/api/26/dataElements the correct >> one for uploading data values via API? >> >> 2. Is the request format correct? >> >> 3. Is there something I need to set on my DHIS instance to make it >> support such operations? >> >> Thanks for your help. >> >> >> -- >> Regards, >> Leke Seweje >> ___ >> Mailing list: https://launchpad.net/~dhis2-devs >> Post to : dhis2-d...@lists.launchpad.net >> Unsubscribe : https://launchpad.net/~dhis2-devs >> More help : https://help.launchpad.net/ListHelp >> > > > -- > Knut Staring > > Department of Information, Evidence and Research > World Health Organization, Geneva, Switzerland > Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 > Skype: knutstar > -- Regards, Leke Seweje >>> >>> >>> -- >>> Knut Staring >>> >>> Department of Information, Evidence and Research >>> World Health Organization, Geneva, Switzerland >>> Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 >>> Skype: knutstar >>> ___ >>> Mailing list: https://launchpad.net/~dhis2-users >>> Post to : dhis2-users@lists.launchpad.net >>> Unsubscribe : https://launchpad.net/~dhis2-users >>> More help : https://help.launchpad.net/ListHelp >>> >> > > -- > Knut Staring > > Department of Information, Evidence and Research > World Health Organization, Geneva, Switzerland > Office: +41 22 791 3683 Mob1: +33 6 4434 2931
Re: [Dhis2-users] [Dhis2-devs] Uploading CSV data file with curl
It is possible: https://docs.dhis2.org/master/en/developer/html/webapi_csv_metadata_import.html Knut On Wed, Jul 4, 2018 at 2:31 PM Vladimer Shioshvili wrote: > Leke, > > While it's good to use --data-binary, in your curl calls in both examples, > you are missing -H switch in front of the content type (look at the example > Knut provided), which makes it default to application/x-www-form-urlencoded. > Make sure you include -H; > > Knut (and others), Leke's original question mentioned dataElements, and it > got me looking too, and i noticed that while the documentation talks about > columns for the metadata csv content, it never gives the API endpoints for > importing metadata using CSV. Is that even possible? There are classes to > handle it in the code, and I know import/export app does it (i've used it), > but what about API? > > Vlad > > On Wed, Jul 4, 2018 at 5:45 AM Knut Staring wrote: > >> Hi Leke, according to the link I sent you have to use --data-binary as in >> this request: >> >> curl --data-binary @datavalueset.csv >> "https://play.dhis2.org/demo/24/api/dataValueSets; >> -H "Content-Type:application/csv" -u admin:district -v >> >> Knut >> >> On Wed, Jul 4, 2018 at 11:35 AM Olaleke Seweje >> wrote: >> >>> Thanks Knut, I tried with dataValueSets and got exactly the same error. >>> Below is what my curl request looked like. >>> >>> curl -d @file.name.csv "http://myHostName/api/26/dataValueSets; -X POST >>> "Content-Type: application/csv" -u username:password >>> >>> >>> *The result* >>> >>> >>> {"httpStatus":"Unsupported Media >>> Type","httpStatusCode":415,"status":"ERROR","message":"Content type >>> 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not >>> resolve host: Content-Type >>> >>> >>> Please what do I need to look into again? >>> >>> Is the format of the curl request correct? >>> >>> Is there something I need to set on my DHIS instance to make it support >>> such operations? >>> >>> >>> >>> On Wed, Jul 4, 2018 at 8:21 AM Knut Staring wrote: >>> Hi Leke, are you sending METADATA or DATA VALUES? If the latter, you need to use dataValueSets: https://docs.dhis2.org/master/en/developer/html/webapi_data_values.html#webapi_sending_data_values Knut On Wed, Jul 4, 2018 at 5:58 AM Olaleke Seweje wrote: > Hi all, > > I am trying to upload data via CURL as specified in the dev docs - 1.9.2. > Creating > and updating objects. My request is as follows: > > > curl -d @file._name.csv "http://myHostName/api/26/dataElements; -X > POST "Content-Type: application/csv" -u username:password > > > > *The response I got was * > > > {"httpStatus":"Unsupported Media > Type","httpStatusCode":415,"status":"ERROR","message":"Content type > 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not > resolve host: Content-Type > > I have tried content type text/csv as well but got similar results. > > My questions > 1. Is my endpoint http://myHostName/api/26/dataElements the correct > one for uploading data values via API? > > 2. Is the request format correct? > > 3. Is there something I need to set on my DHIS instance to make it > support such operations? > > Thanks for your help. > > > -- > Regards, > Leke Seweje > ___ > Mailing list: https://launchpad.net/~dhis2-devs > Post to : dhis2-d...@lists.launchpad.net > Unsubscribe : https://launchpad.net/~dhis2-devs > More help : https://help.launchpad.net/ListHelp > -- Knut Staring Department of Information, Evidence and Research World Health Organization, Geneva, Switzerland Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 Skype: knutstar >>> >>> >>> -- >>> Regards, >>> Leke Seweje >>> >> >> >> -- >> Knut Staring >> >> Department of Information, Evidence and Research >> World Health Organization, Geneva, Switzerland >> Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 >> Skype: knutstar >> ___ >> Mailing list: https://launchpad.net/~dhis2-users >> Post to : dhis2-users@lists.launchpad.net >> Unsubscribe : https://launchpad.net/~dhis2-users >> More help : https://help.launchpad.net/ListHelp >> > -- Knut Staring Department of Information, Evidence and Research World Health Organization, Geneva, Switzerland Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 Skype: knutstar ___ Mailing list: https://launchpad.net/~dhis2-users Post to : dhis2-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-users More help : https://help.launchpad.net/ListHelp
Re: [Dhis2-users] [Dhis2-devs] Uploading CSV data file with curl
Leke, While it's good to use --data-binary, in your curl calls in both examples, you are missing -H switch in front of the content type (look at the example Knut provided), which makes it default to application/x-www-form-urlencoded. Make sure you include -H; Knut (and others), Leke's original question mentioned dataElements, and it got me looking too, and i noticed that while the documentation talks about columns for the metadata csv content, it never gives the API endpoints for importing metadata using CSV. Is that even possible? There are classes to handle it in the code, and I know import/export app does it (i've used it), but what about API? Vlad On Wed, Jul 4, 2018 at 5:45 AM Knut Staring wrote: > Hi Leke, according to the link I sent you have to use --data-binary as in > this request: > > curl --data-binary @datavalueset.csv > "https://play.dhis2.org/demo/24/api/dataValueSets; > -H "Content-Type:application/csv" -u admin:district -v > > Knut > > On Wed, Jul 4, 2018 at 11:35 AM Olaleke Seweje > wrote: > >> Thanks Knut, I tried with dataValueSets and got exactly the same error. >> Below is what my curl request looked like. >> >> curl -d @file.name.csv "http://myHostName/api/26/dataValueSets; -X POST >> "Content-Type: application/csv" -u username:password >> >> >> *The result* >> >> >> {"httpStatus":"Unsupported Media >> Type","httpStatusCode":415,"status":"ERROR","message":"Content type >> 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not >> resolve host: Content-Type >> >> >> Please what do I need to look into again? >> >> Is the format of the curl request correct? >> >> Is there something I need to set on my DHIS instance to make it support >> such operations? >> >> >> >> On Wed, Jul 4, 2018 at 8:21 AM Knut Staring wrote: >> >>> Hi Leke, are you sending METADATA or DATA VALUES? >>> >>> If the latter, you need to use dataValueSets: >>> >>> https://docs.dhis2.org/master/en/developer/html/webapi_data_values.html#webapi_sending_data_values >>> >>> Knut >>> >>> On Wed, Jul 4, 2018 at 5:58 AM Olaleke Seweje >>> wrote: >>> Hi all, I am trying to upload data via CURL as specified in the dev docs - 1.9.2. Creating and updating objects. My request is as follows: curl -d @file._name.csv "http://myHostName/api/26/dataElements; -X POST "Content-Type: application/csv" -u username:password *The response I got was * {"httpStatus":"Unsupported Media Type","httpStatusCode":415,"status":"ERROR","message":"Content type 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not resolve host: Content-Type I have tried content type text/csv as well but got similar results. My questions 1. Is my endpoint http://myHostName/api/26/dataElements the correct one for uploading data values via API? 2. Is the request format correct? 3. Is there something I need to set on my DHIS instance to make it support such operations? Thanks for your help. -- Regards, Leke Seweje ___ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-d...@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp >>> >>> >>> -- >>> Knut Staring >>> >>> Department of Information, Evidence and Research >>> World Health Organization, Geneva, Switzerland >>> Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 >>> Skype: knutstar >>> >> >> >> -- >> Regards, >> Leke Seweje >> > > > -- > Knut Staring > > Department of Information, Evidence and Research > World Health Organization, Geneva, Switzerland > Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 > Skype: knutstar > ___ > Mailing list: https://launchpad.net/~dhis2-users > Post to : dhis2-users@lists.launchpad.net > Unsubscribe : https://launchpad.net/~dhis2-users > More help : https://help.launchpad.net/ListHelp > ___ Mailing list: https://launchpad.net/~dhis2-users Post to : dhis2-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-users More help : https://help.launchpad.net/ListHelp
Re: [Dhis2-users] [Dhis2-devs] Uploading CSV data file with curl
Hi Leke, according to the link I sent you have to use --data-binary as in this request: curl --data-binary @datavalueset.csv "https://play.dhis2.org/demo/24/api/dataValueSets; -H "Content-Type:application/csv" -u admin:district -v Knut On Wed, Jul 4, 2018 at 11:35 AM Olaleke Seweje wrote: > Thanks Knut, I tried with dataValueSets and got exactly the same error. > Below is what my curl request looked like. > > curl -d @file.name.csv "http://myHostName/api/26/dataValueSets; -X POST > "Content-Type: application/csv" -u username:password > > > *The result* > > > {"httpStatus":"Unsupported Media > Type","httpStatusCode":415,"status":"ERROR","message":"Content type > 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not > resolve host: Content-Type > > > Please what do I need to look into again? > > Is the format of the curl request correct? > > Is there something I need to set on my DHIS instance to make it support > such operations? > > > > On Wed, Jul 4, 2018 at 8:21 AM Knut Staring wrote: > >> Hi Leke, are you sending METADATA or DATA VALUES? >> >> If the latter, you need to use dataValueSets: >> >> https://docs.dhis2.org/master/en/developer/html/webapi_data_values.html#webapi_sending_data_values >> >> Knut >> >> On Wed, Jul 4, 2018 at 5:58 AM Olaleke Seweje >> wrote: >> >>> Hi all, >>> >>> I am trying to upload data via CURL as specified in the dev docs - 1.9.2. >>> Creating >>> and updating objects. My request is as follows: >>> >>> >>> curl -d @file._name.csv "http://myHostName/api/26/dataElements; -X POST >>> "Content-Type: application/csv" -u username:password >>> >>> >>> >>> *The response I got was * >>> >>> >>> {"httpStatus":"Unsupported Media >>> Type","httpStatusCode":415,"status":"ERROR","message":"Content type >>> 'application/x-www-form-urlencoded' not supported"}curl: (6) Could not >>> resolve host: Content-Type >>> >>> I have tried content type text/csv as well but got similar results. >>> >>> My questions >>> 1. Is my endpoint http://myHostName/api/26/dataElements the correct one >>> for uploading data values via API? >>> >>> 2. Is the request format correct? >>> >>> 3. Is there something I need to set on my DHIS instance to make it >>> support such operations? >>> >>> Thanks for your help. >>> >>> >>> -- >>> Regards, >>> Leke Seweje >>> ___ >>> Mailing list: https://launchpad.net/~dhis2-devs >>> Post to : dhis2-d...@lists.launchpad.net >>> Unsubscribe : https://launchpad.net/~dhis2-devs >>> More help : https://help.launchpad.net/ListHelp >>> >> >> >> -- >> Knut Staring >> >> Department of Information, Evidence and Research >> World Health Organization, Geneva, Switzerland >> Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 >> Skype: knutstar >> > > > -- > Regards, > Leke Seweje > -- Knut Staring Department of Information, Evidence and Research World Health Organization, Geneva, Switzerland Office: +41 22 791 3683 Mob1: +33 6 4434 2931 Mob2: +47 9188 0522 Skype: knutstar ___ Mailing list: https://launchpad.net/~dhis2-users Post to : dhis2-users@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-users More help : https://help.launchpad.net/ListHelp