Skip to content

Instantly share code, notes, and snippets.

@umiphos
Created March 31, 2020 14:50
Show Gist options
  • Save umiphos/5a51aed5623e74035ff7ea037068ea49 to your computer and use it in GitHub Desktop.
Save umiphos/5a51aed5623e74035ff7ea037068ea49 to your computer and use it in GitHub Desktop.
This is a simulation of a client that will send information to the IAP server
import requests
import json
server_url = 'http://127.0.0.1:8069/iap/1.0/l10n_pe_edi_digiflow'
headers = {
'Content-Type': 'application/json',
}
xml_root = 'PEludm9pY2UgeG1sbnM6Y2N0cz0idXJuOnVuOnVuZWNlOnVuY2VmYWN0OmRvY3VtZW50YXRpb246MiIgeG1sbnM6Y2FjPSJ1cm46b2FzaXM6bmFtZXM6c3BlY2lmaWNhdGlvbjp1Ymw6c2NoZW1hOnhzZDpDb21tb25BZ2dyZWdhdGVDb21wb25lbnRzLTIiIHhtbG5zOmRzPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzA5L3htbGRzaWcjIiB4bWxucz0idXJuOm9hc2lzOm5hbWVzOnNwZWNpZmljYXRpb246dWJsOnNjaGVtYTp4c2Q6SW52b2ljZS0yIiB4bWxuczpjYmM9InVybjpvYXNpczpuYW1lczpzcGVjaWZpY2F0aW9uOnVibDpzY2hlbWE6eHNkOkNvbW1vbkJhc2ljQ29tcG9uZW50cy0yIiB4bWxuczpzYWM9InVybjpzdW5hdDpuYW1lczpzcGVjaWZpY2F0aW9uOnVibDpwZXJ1OnNjaGVtYTp4c2Q6U3VuYXRBZ2dyZWdhdGVDb21wb25lbnRzLTEiIHhtbG5zOnFkdD0idXJuOm9hc2lzOm5hbWVzOnNwZWNpZmljYXRpb246dWJsOnNjaGVtYTp4c2Q6UXVhbGlmaWVkRGF0YXR5cGVzLTIiIHhtbG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFuY2UiIHhtbG5zOmV4dD0idXJuOm9hc2lzOm5hbWVzOnNwZWNpZmljYXRpb246dWJsOnNjaGVtYTp4c2Q6Q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M6VGF4VHlwZUNvZGU+PC9jYWM6VGF4U2NoZW1lPjwvY2FjOlRheENhdGVnb3J5PjwvY2FjOlRheFN1YnRvdGFsPjwvY2FjOlRheFRvdGFsPjxjYWM6SXRlbT48Y2JjOkRlc2NyaXB0aW9uPkN1c3RvbWl6YWJsZSBEZXNrIChDT05GSUcpPC9jYmM6RGVzY3JpcHRpb24+PGNhYzpDb21tb2RpdHlDbGFzc2lmaWNhdGlvbj48Y2JjOkl0ZW1DbGFzc2lmaWNhdGlvbkNvZGU+MTAxMDE1MDI8L2NiYzpJdGVtQ2xhc3NpZmljYXRpb25Db2RlPjwvY2FjOkNvbW1vZGl0eUNsYXNzaWZpY2F0aW9uPjwvY2FjOkl0ZW0+PGNhYzpQcmljZT48Y2JjOlByaWNlQW1vdW50IGN1cnJlbmN5SUQ9IlBFTiI+NS41NjwvY2JjOlByaWNlQW1vdW50PjwvY2FjOlByaWNlPjwvY2FjOkludm9pY2VMaW5lPjwvSW52b2ljZT4='
data = '{"params": {"dbuuid":"123","vat":"20557912879","token":"1234", "xml": %s}}' % xml_root
requests.post(server_url, headers=headers, data=data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment