import requests, json headers = { 'X-WMO-WMDR-Token' : "438jgruighiufgh89rthg893h4289" } # FIXME: update token filename = '1-create-station.xml' #FIXME: update filename with open(filename, 'r') as content_file: content = content_file.read() response = requests.post('https://oscardepl.wmo.int/surface///rest/api/wmd/upload' , data=content , headers=headers ) if response.status_code == 200: # reponse: {"id":18,"xmlStatus":"SUCCESS_WITH_WARNINGS","logs":"The XML has been parsed with the following exceptions/issues:\nREF_5: ReferenceType for \"Reporting/uom\" with URL \"http://codes.wmo.int/common/unit/ppbv\" could not be found. Information for \"Reporting/uom\" is discarded.\n"} response = json.loads(response.content) if response["xmlStatus"] in ['SUCCESS_WITH_WARNINGS','SUCCESS']: print("upoaded ok, new id {id}".format(id=response["id"])) else: print("upload failed.. the log is {logs}".format(logs=response["logs"]) ) else: print("processing error on server side")