SSRS Session API

MrOutside 1 Reputation point
2022-04-12T05:08:26.84+00:00

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 Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,873 questions
Microsoft Partner Center API
Microsoft Partner Center API
Microsoft Partner Center: A Microsoft website for partners that provides access to product support, a partner community, and other partner services.API: A software intermediary that allows two applications to interact with each other.
328 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Isabellaz-1451 3,616 Reputation points
    2022-04-15T09:11:55.51+00:00

    Hi @MrOutside

    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.

    0 comments No comments