I am trying to build a Webservice API using python flask. When I execute this code below:
http://localhost/Service/API/Services.svc/XMLService/Students?SEARCHBY=StudentNo&STUDENTNUMBER='1234'&SESSIONKEY=94194202323
...it works fine. But I could not pass STUDENTNUMBER
to this function.
I have tried two ways:
Concat build a string and pass it to
c.setopt(c.URL,)
this functiona. Way 1
b. Way 2
c. Way 3
Via those ways I got the same error:
TypeError: invalid arguments to
setopt
Pass the variable using c.setopt(c.POSTFIELDS, post_data)
a. Way 4
This way I got the same error:
Method not allowed. Please see the for constructing valid requests to the service
So that I am going to this link:
b. Way 5
This way I got the same error
TypeError: invalid arguments to
setopt
Way 1:
student_url = " http://localhost/Service/API/Services.svc/XMLService/Students?SEARCHBY=StudentNo&STUDENTNUMBER=%s&SESSIONKEY=94194202323"%student_number;
c.setopt(c.URL,student_url)
Way 2:
c.setopt(c.URL,"http://localhost/Service/API/Services.svc/XMLService/Students?SEARCHBY=StudentNo&STUDENTNUMBER=%s&SESSIONKEY=94194202323"%(student_number))
Way 3:
c.setopt(c.URL,"http://localhost/Service/API/Services.svc/XMLService/Students?SEARCHBY=StudentNo&STUDENTNUMBER=%s&SESSIONKEY=94194202323"%student_number)
Way 4:
c.setopt(c.URL,"http://localhost/Service/API/Services.svc/XMLService/Students?SEARCHBY=StudentNo&STUDENTNUMBER=%s&SESSIONKEY=94194202323")
c.setopt(c.POSTFIELDS, 'STUDENTNUMBER = 1234')
Way 5:
post_data ={'STUDENTNUMBER' : '1234'}
c.setopt(c.URL,"http://localhost/Service/API/Services.svc/XMLService/Students?SEARCHBY=StudentNo&SESSIONKEY=94194202323")
c.setopt(c.POSTFIELDS, post_data)
c.setopt(pycurl.POST, 1)
How can I make this work?