Seeking help with urllib2 reasponse reading

Joined
Aug 3, 2010
Messages
1
Reaction score
0
Hi All,

I am trying to access XMLAPI using python. I am getting weird behavior from server, when reading response.

Code for calling XMLAPI is as follows:

headers = {'Content-type': 'application/x-www-form-urlencoded'}
request = urllib2.Request(siteXMLAPIURL,xmlStr,headers)
response = urllib2.urlopen(request)
print response.read()


In above code,
xmlStr: is String containing XML file

siteXMLAPIURL: URL of the site to send request. It is in form "https://xxx.xxx.com/XXXService/XXXService

Problem Description:
I am calling URL for creating product by passing methodname(CreateProduct), productId, productCreateDate, productCreateTime etc in XML form.

Call to XMLAPI always succeed and product is created on site. But when I call .read() method to print response, then "productCreateTimes" gets changed on server !!

For example,
Case 1: Not using .read() method. (i.e. commenting print line in above code)
Calling API by passing productCreateTime = 08/02/10 08:00:00,and then product is being created with time 08/02/10 08:00:00. i.e. everything is fine here

Now,
Case 2: Using read() method (i.e. having print line is code)
Calling API by passing productCreateTime = 08/02/10 08:00:00 and then product is being created with time 08/02/10 09:00:00. Here, server is adding one more hour to productCrateTime. Which is really strange for me!!

FYI: If I access same API with java, everything is fine all time.

I am unable to understand why read() method is changing server behavior!! Can anyone please guide me in same?

Thank you so much for your time. Hoping for reply !!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top