Re: [Tutor] python file upload

2011-05-14 Thread Brett Ritter
On Friday, May 13, 2011, Rayon evosw...@hotmail.com wrote:
 Hi all, I need a python script to upload a xml file to a web page using 
 python. I have tried using pycurl but I am still getting

Fyi, the XML spec allows for no characters or whitespace before the
XML declaration, that could be your error,

-- 
Brett Ritter / SwiftOne
swift...@swiftone.org
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] python file upload

2011-05-13 Thread Rayon
Hi all, 

I need a python script to upload a xml file to a web page using python. 

I have tried using pycurl but I am still getting errors. 

 

import urllib2

import pycurl

 

data=

?xml version=1.0 encoding=UTF-8?

!DOCTYPE ProvisioningRequest SYSTEM ProvisioningRequest.dtd

ProvisioningRequest TransactionId=000332 Version=1.2
TransactionType=Activate ProductType=BlackBerry

Header

Sender id=349114 name=GTT

Logingtt_admin/Login

PasswordPassword2011/Password

/Sender

TimeStamp2001-11-15T13:18:08-08:00/TimeStamp

/Header

Body

ProvisioningEntity name=subscriber

ProvisioningDataItem
name=BillingId738002000417469/ProvisioningDataItem

ProvisioningEntity name=service

ProvisioningDataItem name=ServiceNameEnterprise
B/ProvisioningDataItem

/ProvisioningEntity

/ProvisioningEntity

/Body

/ProvisioningRequest



 

headers = [Content-Type:text/xml]

#data = open(d:\\dump\\activation.xml)

c = pycurl.Curl()

c.setopt(c.URL, https://provisioning.etr.blackberry.net/ari/submitXML;)

c.setopt(pycurl.POST,1)

c.setopt(pycurl.SSL_VERIFYPEER, 0)

c.setopt(pycurl.SSL_VERIFYHOST, 0) 

c.setopt(pycurl.HTTPHEADER, headers)

c.setopt(pycurl.POSTFIELDS, data)

c.setopt(c.VERBOSE, 1)

c.perform()

c.close()

 

this is the error I am getting. 

* About to connect() to provisioning.etr.blackberry.net port 443 (#0)

*   Trying 216.9.243.178... * connected

* Connected to provisioning.etr.blackberry.net (216.9.243.178) port 443 (#0)

* libcurl is now using a weak random seed!

* SSL connection using RC4-MD5

* Server certificate:

*  subject: C=CA; ST=Ontario; L=Waterloo; O=Research In Motion
Limited; OU=IT; CN=provisioning.etr.blackberry.net

*  start date: 2011-03-28 00:00:00 GMT

*  expire date: 2012-03-27 23:59:59 GMT

*  issuer: C=US; O=Thawte, Inc.; CN=Thawte SSL CA

*  SSL certificate verify result: self signed certificate in
certificate chain (19), continuing anyway.

 POST /ari/submitXML HTTP/1.1 User-Agent: PycURL/7.19.7 Host:
provisioning.etr.blackberry.net Accept: */* Content-Type:text/xml
Content-Length: 836   HTTP/1.1 500 Internal Server Error  Connection:
close  Date: Fri, 13 May 2011 18:35:24 GMT  Content-Length: 90 
Content-Type: text/html  X-Powered-By: Servlet/2.5 JSP/2.1   * Closing
connection #0

ERROR_ID=PARSEING_ERROR

DESCRIPTION=Request parsing failed: Tag in line:2 Ending column:6

 

 

Regards Rayon

 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor