Private Function dhis2APIpostJSON(strURL As String, strUsr As String, strPwd As String, strJSON As String) As String
Dim MyRequest As Object
On Error GoTo dhis2APIpostErr
For the CSV - I tried the following:
MyRequest.setRequestHeader “Content-Type”, “application/csv”
and passed CSV looked like this:
Name,UID,ShortName,Parent
Sample Location 1,Z1raiKJH6yv,Sample Location 1,PqlFzhuPcF1
Any advise or direction to where I’m going wrong please advise. Thanks in advance.
CSV import for orgUnits is a little bit picky. I’ve observed that you need to have all the fields even if they are not required.
Try with this sample we use to import OUs with coordinates (I had to attach it as .xls) csvOrgUnit.xls (34 KB) . Watch out the Opening Date field format when converting to CSV (it has to follow the pattern YYYY-MM-DD, might be recognised as a date)
@jomutsani, perhaps CoP should also allow to attach .csv files in the platform as is a common format used in DHIS2.
I ended up figuring it out by investigating the format that the API takes when doing it from the web app. For anyone looking for this (and similarly for other metadata types such as Data Elements) my import script looks like this.
Private Function dhis2APIpostCSV(strURL As String, strUsr As String, strPwd As String, strCSVFilePath As String, ClassKey As String) As String
Dim Data As String