question

MrOutside-3292 avatar image
0 Votes"
MrOutside-3292 asked Isabellaz-1451 answered

SSRS Session API

I have a python app that i am building that needs to delete and upload images to SSRS.
The issue i have is to authenticate against the ssrs api the documentation says i should specify username, password and domain and should get a token back.
For some reason i keep getting 401 or 400 error when i try to generate a session.

i am using the api documentation here: https://app.swaggerhub.com/apis/microsoft-rs/SSRS/2.0#/Session/CreateSession

Here is the part of my code that will not authenticate i have no idea why

user = ''
pwd = ''
domain = ''
report_url = ''

import requests
import json
class ssrs():

  def __init__(self,Org,user,pwd):
      self.org                = Org
      self.user               = user
      self.pwd                = pwd
      self.verifcationErrors  = []
  def authorize(self):
      try:
          self.url = f"http://{self.org}/reports/api/v2.0/Session"
          self.payload = json.dumps({"username": f"{self.user}","password": f"{self.pwd}"})
          self.header = {'Content-Type': 'application/json', 'Accept': 'application/json'}
          self.response = requests.request("POST", self.url, headers=self.header, auth=self.payload)
          return self.response.status_code
      except Exception as e:
          return e

var = ssrs(Org=report_url,user=user, pwd = pwd).authorize()
print(var)

Looking for some help on others that have been able to successfully connect to ssrs and run rest api commands

pd: i also tried using

from requests_negotiate_sspi import HttpNegotiateAuth
auth=HttpNegotiateAuth()

to provide credentials and it didn't work either










sql-server-reporting-servicespartner-center-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Isabellaz-1451 avatar image
0 Votes"
Isabellaz-1451 answered

Hi @MrOutside-3292

Sorry,I am not familiar to the python.
Here is a sample code about deploying a custom security extension to SQL Reporting Services 2017,you may take a reference.
https://github.com/microsoft/Reporting-Services/tree/master/CustomSecuritySample
and here is the article I take reference:
https://stackoverflow.com/questions/56993367/how-to-call-ssrs-rest-api-v2-0-with-custom-security-implemented-not-soap-using
Hope this will help you.

Best Regards,
Isabella


If the answer is the right solution, please click "Accept Answer" and upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.