def delete_last_uploaded_attachment(url, attachment, token): payload = bytearray(attachment, 'utf-8') header = {'Authorization': 'Bearer ' + token, 'content-type': 'text/xml', 'Content-Disposition': 'attachment; filename=mva-vedlegg.xml'} response = requests.request("DELETE", url, headers=header, data=payload) printing(response)
def upload(url, melding_xml, token): payload = bytearray(melding_xml, 'utf-8') header = { 'Authorization': 'Bearer ' + token, 'content-type': 'text/xml', 'Content-Disposition': 'attachment; filename=mva-melding.xml' } response = requests.request("POST", url, headers=header, data=payload) printing(response)
def upload(url, attachment, content_type, token): with open("./eksempler/" + attachment, 'rb') as file: payload = file.read() header = {'Authorization': 'Bearer ' + token, 'content-type': content_type, 'Content-Disposition': 'attachment; filename=' + attachment} response = requests.request("POST", url, headers=header, data=payload) printing(response) return response
def upload(url, konvolutt_xml, token): payload = bytearray(konvolutt_xml, 'utf-8') header = { 'Authorization': 'Bearer ' + token, 'content-type': 'application/xml', 'Content-Disposition': 'attachment; filename=konvolutt.xml' } response = requests.request("PUT", url, headers=header, data=payload) printing(response)
def get(header): if header is None: print("Something went wrong. header = None") return url = "https://platform.tt02.altinn.no/authentication/api/v1/exchange/id-porten" header["content-type"] = "application/json" response = requests.request("GET", url, headers=header) printing(response) return response.content.decode("utf-8")
def create(domain, token, app, org_number): url = domain + app + "/instances/" header = { 'Authorization': 'Bearer ' + token, 'content-type': 'application/json' } payload = "{'instanceOwner': {'organisationNumber': " + org_number + "}}" instance = requests.request("POST", url, headers=header, data=payload) printing(instance) return instance.json()
def get(url, token): header = {'Authorization': 'Bearer ' + token} instance = requests.request("GET", url, headers=header) printing(instance) return instance.json()