Sample web service script in any language

  • 3
  • Question
  • Updated 3 years ago
  • Answered
I'm trying to figure out how to login to the web services area (Replicon Gen 3) using literally any language. The only example code available in the documentation is meant for the Gen 2 API, which doesn't really help. I'm able to see the web service list at this URL: https://na2.replicon.com//services/he..., but I don't know how to interact with it. Let's say I'm going to use C# to write a script to create a new project. How would I do that? I think I need to use ProjectService1, but that's all I know at this point because I'm stuck before I can even start interacting with the web services. I need to login to programmatically login to the page. At this point, any code would be helpful even if it wasn't in C#. I could at least look at it and understand how the web services are supposed to be used. I can't find a single piece of code on Replicon's website for Gen 3 to get me started.

(Originally posted by bandtank)
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes

Posted 4 years ago

  • 3
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes
Hi,

Thank you for using Replicon Community.

We have attached a sample program written on python for Gen3 web services. 



Thanks,

Lingaraj



 

(Originally posted by Lingaraj Dharwad)
Photo of alex karpow

alex karpow

  • 1 Post
  • 0 Reply Likes

Hi - can I possibly get a copy of the sample program written on python for Gen3 web services.

Thanks

Alex

Photo of Gautham Amalakumar

Gautham Amalakumar, Tier 3 Engineer

  • 7 Posts
  • 3 Reply Likes
Hi Alex,

Here is the Sample Code for Getting all users from the system.

import json
import requests
from requests.auth import HTTPBasicAuth

#Details of the instance
company_name = 'CompanyKey' #Replace the field with original company key
user_name = 'LoginName' #Replace the field with Login Name
pwd = 'Password' #Replace the field with password

#Header for Service Call
headers = {'content-type':'application/json'}

#Finding Domain URL
#This is to get the Domain URL of the instance, hence no authentication required.
domainfinderurl = 'https://global.replicon.com/DiscoveryService1.svc/GetUserIntegrationDetails'
domainfinderval = {'companyKey' : company_name, 'loginName' : user_name, 'targetUrl' : None}
domainfinder = requests.post(domainfinderurl,headers=headers,data=json.dumps(domainfinderval))
domainfinder = domainfinder.json()

domainurl = domainfinder['d']['serviceEndpointRootUrl']

#URLs
allusersurl = domainurl+'UserService1.svc/GetAllUsers'`

#Service Call for Getting all users and uris
print 'Getting All Users ...'
allusers = requests.post(allusersurl,headers=headers,auth=(company_name+'\\'+user_name, pwd))
allusers = allusers.json()

print 'Login Name,User Uri'

if allusers.get('error') == None:

for user in allusers['d']:

print '"%s","%s"' %(user['loginName'], user['uri'])

else:

print 'Error|| %s' %(allusers.get('error')['reason'])
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes
Yes, that helps a lot. Thank you. I had to comment out the with block looking for add.csv because I don't know what's supposed to be in it. Do you have an example add.csv file? It would be extremely helpful. For anyone else looking at this, the following lines are an example of a config.ini file (the example script is looking for a file with that name) in case you aren't familiar with ConfigParser: [project_team_update] cname: username: password: If you're using python 2.x on Windows, you'll have to install the requests module as it isn't packaged in the default distribution. The script will fail unless you exit before it tries to read add.csv. I put the following lines after all_clients = allclients(): print all_clients exit() I was able to verify proper operation because the list of clients in my replicon instance were correctly retrieved from the webservice. Very cool.

(Originally posted by bandtank)