Errors while running services from python script

  • 1
  • Question
  • Updated 4 years ago
Running this code results in an error even though running it from services/help works as expected. The input data is a string, so the payload should simply be a string, right? Well, it gives an internal error, so either the code given to me in another thread doesn't work for all data types or something is wrong with the back end code. It's probably the former, but with no documentation I don't know how to make it work. def runService(query,payload): headers = {'content-type':'application/json'} url = 'https://na2.replicon.com/' + company + '/services/' + query r=requests.post(url, headers = headers, auth=(company + '\\' + username, password), data = json.dumps(payload), timeout = 60) return r.json() runService('ClientService1.svc/GetUriFromSlug', "testClient2") There's a client called testClient2 in my Replicon instance and the URI is successfully returned through the web interface. What's going on?

(Originally posted by bandtank)
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes

Posted 4 years ago

  • 1
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes
Hi,

Thank you for using Replicon Community.

Since the script works via services/help, we will need to investigate this further. Kindly contact the support team so that they can setup a call and help address this issue. 

Thanks,

Lingaraj



(Originally posted by Lingaraj Dharwad)
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes
Hi There. You are passing a payload to runService(query,payload), which is consumed by json.dumps(payload). json.dumps expects a dict object, not a string. Please try passing { "clientSlug": null } Edit - TYpo

(Originally posted by Saurabh Verma)