0

How can I send an xml file to a Django app server from a command line interface?

I tried using curl, but the data I get on the Django side becomes a dictionary and doesn't look like xml. In addition to that I need some basic authorization mechanism. I tried curl examples, but to no avail. Maybe I am expecting the wrong thing. Can someone guide me to the right tutorial or examples.

1 Answers1

0

request.body should contain the XML as string.

I tried using curl, but the data I get on the Django side becomes a dictionary

Can you please share the code blocks to receive/print the data?

moonstruck
  • 2,729
  • 2
  • 26
  • 29
  • Thanks. Please let me bug you a little more. How can I give some king of authentication in the curl command so that I can verify the xml file? – Hussain Nagri May 13 '15 at 13:10
  • How you are trying to authenticate? Using cookie, access tocken, GET/POST credentials or something else? – moonstruck May 13 '15 at 13:14
  • I was doing this. `curl -X POST --user "admin:admin" -H "Accept: application/xml" http://localhost:8000/receive/ -d @myscan.xml'` but I think its wrong. I need something where I can validate the username/password or a token on Djnago app. – Hussain Nagri May 13 '15 at 13:19
  • This has been answered [here](http://stackoverflow.com/questions/21306515/how-to-curl-an-authenticated-django-app) It seems you're trying to provide API. Have a look at [Django REST framework](http://www.django-rest-framework.org/) – moonstruck May 13 '15 at 13:42