HI ,
I am pretty new to python and wanted help with below code? All I am trying to do is to make a project name and post it to API website. Not sure if my code is correct? This is not working, I don’t grt any error s but the code look slike by passess the createPRoject portion and ends with no errors?
Process finished with exit code 0
Thanks a bunch!
Pasi
I am pretty new to python and wanted help with below code? All I am trying to do is to make a project name and post it to API website. Not sure if my code is correct? This is not working, I don’t grt any error s but the code look slike by passess the createPRoject portion and ends with no errors?
Process finished with exit code 0
Thanks a bunch!
Pasi
import datetime
from pip._vendor import requests
import requests
import urllib2
import glsapiutil
import urllib
import _auth_tokens
globals()
TODAY = ""
def getToday():
now = datetime.datetime.now()
strToday = str(now.year) + "-"
tmp = str(now.month)
if len(tmp) == 1:
tmp = "0" + tmp
strToday += (tmp + "-")
tmp = str(now.day)
if len(tmp) == 1:
tmp = "0" + tmp
strToday += tmp
return strToday
encoding = "utf-8"
def createProject (pName, udfs , pDate):
print (pName, udfs, pDate)
# print(pName, udfs, pDate)
global r
global post_response
global d
r.encoding = "utf-8"
pName = "Prj123"
udfs = “UT231”
pDate = getToday()
url1Project = "mytestdotcom/ri/project"
urludfs = ' mytestdotcom/ri/userdefined'
pName = "Prj123"
post_data = {'username': "ra", 'password': "mypasswrd"}
post_response = requests.post("testdotcom/api/v2/projects", data=post_data)
r = requests.post(url1Project, data=createProject)
print (r.text)
# print response
def main():
global api
# global ARGS
api = glsapiutil.glsapiutil()
# api.setup(_auth_tokens.API_USERNAME, _auth_tokens.API_PASSWORD)
# #api.setURI(args.stepURI)
# #api.setup(args.username, args.password)
# global TODAY
# api = glsapiutil.glsapiutil()
if __name__ == "__main__":
main()
