if response.status_code == 201:
print("Data posted successfully.")
else:
print(f"Failed to post data. Status code: {response.status_code}")
print(response.text)
except requests.exceptions.RequestException as e:
print("An error occurred: ", e)
I am trying to post data in another DHIS2 system but am getting this error Request URL: https://3pm.nascop.org/api/dataValueSets
Failed to post data. Status code: 404
Kindly ignore the first error posted. Below is the error displayed
Request URL: 3PM
Failed to post data. Status code: 200
{“responseType”:“ImportSummary”,“status”:“SUCCESS”,“importOptions”:{“idSchemes”:{},“dryRun”:false,“async”:false,“importStrategy”:“CREATE_AND_UPDATE”,“mergeMode”:“REPLACE”,“reportMode”:“FULL”,“skipExistingCheck”:false,“sharing”:false,“skipNotifications”:false,“skipAudit”:false,“datasetAllowsPeriods”:false,“strictPeriods”:false,“strictDataElements”:false,“strictCategoryOptionCombos”:false,“strictAttributeOptionCombos”:false,“strictOrganisationUnits”:false,“requireCategoryOptionCombo”:false,“requireAttributeOptionCombo”:false,“skipPatternValidation”:false,“ignoreEmptyCollection”:false,“force”:false,“firstRowIsHeader”:true,“skipLastUpdated”:false,“mergeDataValues”:false,“skipCache”:false},“description”:“Import process completed successfully”,“importCount”:{“imported”:0,“updated”:1,“ignored”:0,“deleted”:0},“conflicts”:,“dataSetComplete”:“false”}
PS C:\Users\WImamai\OneDrive - Center For International Health, Education and Biosecurity - Kenya\Desktop\Ciheb\All_docs\Ciheb_script>
Thanks-@Gassim the status code : 201 is not met, the value is not created or updated on the entry screen but shows import successful. How can I go about that?
I completely agree with you @Stephan_Mestach, thanks! It does show SUCCESS and says that the object has been updated.
The response indicates that the object is not created but that it actually got updated which means that it was created before the request. Maybe it was created in your previous requests so when you tried again, it only got updated?