Forum Discussion

pdbenbow's avatar
pdbenbow
Resolver II
8 years ago

Report Server REST API - PUT method failing

Power BI report server version 1.1.6514.9163 (October 2017)

 

I'm writing a Python app to interact with the REST API. I'm pretty new to OData and REST, and so far I've successfully called several GET methods, but I started having a lot of trouble as soon as I switched over to PUT, POST, PATCH, etc. 

 

Here's a snippet of my Python which invokes the PUT method to update a given report's description field in the Catalog. I've been doing my best to mirror the documentation on SwaggerHub here.

 

    def update_report(self, report_id, description):
        path = self.path + '/CatalogItems({:s})/Properties'.format(report_id)
        payload = {"description": description}
        return requests.put(path, 
                            # data = json.dumps(payload),
                            json = payload, 
                            auth = HttpNtlmAuth(self.username, self.password))

myResponse = rs.update_report(
"67d2c423-aeb5-4893-8db8-d6ae59dff412",
"This is a test to update the report description")

When I run this code, the Python console spits back the following error:


requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost/PBIReports/api/v2.0/CatalogItems(67d2c423-aeb5-4893-8db8-d6ae59dff412)/Properties

 

And this is the response I'm getting from the service:

{
  "error":{
    "code":"","message":"No HTTP resource was found that matches the request URI 'http://localhost/PBIReports/api/v2.0/CatalogItems(67d2c423-aeb5-4893-8db8-d6ae59dff412)/Properties'.","innererror":{
      "message":"No action was found on the controller 'CatalogItemsController' that matches the request.","type":"","stacktrace":""
    }
  }
}

Any ideas as to what I'm doing wrong? The JSON payload should be in good shape, and I know the auth works fine because it works on all my GET calls.

6 Replies

  • v-yulgu-msft's avatar
    v-yulgu-msft
    Microsoft Employee

    Hi pdbenbow,

     

    Unfortunately, I am not familiar with this problem. After research, I could not find the specific cause to this error. 

     

    mgmeyer and jtarquino might have any comment on this problem.

     

    Regards,
    Yuliana Gu

  • edugonz's avatar
    edugonz
    Frequent Visitor

    Just by looking at the code snipped it seems that you are sending a plan json object, but the API expects an array. The shape of the object that you are sending is also incorrect, it should be an object with two properties (name, value))

    • hugoberry's avatar
      hugoberry
      Responsive Resident

      By the way do you set "Content-Type: application/json" in your header?

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi pdbenbow 

     

    Did you resolve this?

     

    I seem to encounter the same issue on our report server when trying to update connectionstring in an embedded datasource. The get request works as expected.

    Server Version 1.5.7074.36177 (May 2019)

     

    This is the code I´m using and getting 400 Bad request.

    Any ideas?

     

    import json
    import requests
    from requests_negotiate_sspi import HttpNegotiateAuth
    
    uri = 'http://###/api/v2.0/PowerBiReports(0d78ce2d-35a4-424a-8c4a-42556b91776c)/DataSources'
    
    payload = {'ConnectionString': 'data source=###;initial catalog=###;persist security info=false'}
    
    headers = {'Content-type': 'application/json'}
    
    r = requests.patch(uri, auth=HttpNegotiateAuth(), json=payload, headers=headers)
    #r = requests.get(uri, auth=HttpNegotiateAuth())
    
    print(r.status_code)
    print(r.content)
    print(r.headers)
    print(r.json)

     

     

    • pdbenbow's avatar
      pdbenbow
      Resolver II

      I never attempted to resolve the issue because this was not a high-priority project for me. I haven't tried any of the suggestions offered by other users, but there's probably some good advice there if you want to try to resolve it.