Forum Discussion
Swagger URL for PBI Report Server
- 8 years ago
If you just want the JSON file you can get it from SwaggerHub here:
https://app.swaggerhub.com/apis/microsoft-rs/PBIRS/2.0
In the top right you'll see an arrow pointing down, click that and you should see and option to download the JSON. I just noticed that there were some codegen customisations that we missed for PBIRS but added for SSRS which may be why your getting compilation errors, I just added them in I'll try it on my end to make sure it works. However if you still want to try the editor let me know if you see any issues.
Matt M.
Hi Martin
Could you successful use the generated API Client from Swagger HUB? Did you find source code examples for C# how to use the client?
I read the readme.md, could compile the "csharp-client-generated" Project (had to fixe some things there) but now I have no idea how to use the IO.Swagger and connect my PBI Report Server.
Greetings, Roli
OK, here my experiences with the Swagger on 2018-02-03 (can vary if you do it after that date because of updates)
Create IO.Swagger Assembly
- Go to https://app.swaggerhub.com/apis/microsoft-rs/PBIRS/2.0
- Ignore Error Message on Website: "Semantic error at parameters.LargeFileMultipartFile"
- Download (green arrow on top right corner) the Client, csharp. Unzip it
- Open Solution IO.Swagger.sln (I use VS 2015)
- Note: There are missing references in both projects.
- In VS 2015, got to menu "Tools", "NuGet Package Manager", "Package Manager Console"
- There is a message "Some NuGet packages are missing from this solution". Click on "Restore". This donwloads the packages and adds the folder "packages" to your solution folder structure, containing "Newtonsoft.Json.10.0.3", "NUnit.2.6.4", "RestSharp.105.1.0"
- In the two projects, go to the missing references (RestSharp, nunit.framework) and set property "Copy Local = true"
- Build the solution with F6
- you get a lot of errors. Fix that:
- Error: "'xy.ToJson()': cannot override inherited member...". Declare methods as virtual so that they can be overridden:
- CatalogItem.ToJson():
- public virtual string ToJson()
ManifestItem.ToJson()
public virtual string ToJson()
- CatalogItem.ToJson():
- Error: "The name 'BaseValidate' does not exists in the current context"
- Outcomment all the mentioned methods in many classes:
- //IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
//{
// foreach(var x in BaseValidate(validationContext)) yield return x;
// yield break;
//}
- //IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
- Build the solution with F6
- successful
- Now build the solution like it is described in the README.md
- That gives you a folder "bin" in your soltion folder with 4 files:
- IO.Swagger.dll
- IO.Swagger.xml
- Newtonsoft.Json.dll
- RestSharp.dll
- That gives you a folder "bin" in your soltion folder with 4 files:
Use IO.Swagger Assembly in your Application
- Add referenced to this three dll files
- In your source code, do this (as example to get all Catalog Items):
- Add usings
using IO.Swagger.Api; using IO.Swagger.Client; using IO.Swagger.Model; using RestSharp;
- Code
var clientCI = new CatalogItemsApi(apiString); clientCI.Configuration.ApiClient.RestClient.Authenticator = new NtlmAuthenticator(CredentialCache.DefaultCredentials); ODataCatalogItems cItems = clientCI.GetCatalogItems();
Happy coding!
Roli
- figuerres8 years agoNew Member
hey i guess the generated code has changed and there is one more problem with it.
i got the C# client coe and this one part does not compile and i amtrying to see what the right whay is to make it work.
in apiclient.cs at about line number 138 is a bit of code like this:request.AddFile( param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType );now the item param.Value.Writer is of type Action<T> where T is a Stream
the parameter on AddFile ( ... ) wants an array of byte
so i need to get the stream and then the bytes if this was not an Action<T> id have no problem.
but I am not familiar with that.
any ideas on what should be done here ??
- figuerres8 years agoNew Member
hey i guess the generated code has changed and there is one more problem with it.
i got the C# client coe and this one part does not compile and i amtrying to see what the right whay is to make it work.
in apiclient.cs at about line number 138 is a bit of code like this:request.AddFile( param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType );now the item param.Value.Writer is of type Action<T> where T is a Stream
the parameter on AddFile ( ... ) wants an array of byte
so i need to get the stream and then the bytes if this was not an Action<T> id have no problem.
but I am not familiar with that.
any ideas on what should be done here ??
- figuerres8 years agoNew Member
so i found that this is related to a new build of RestSharp, i had to go to an older version to make it build.
so i gess the swagger hub generated code and RestSharp are not playing well together....
- StolzHerz8 years agoHelper I
The choice of Microsoft to use a Rest Api / Swagger looks very trendy, but from the point of view of a Visual Studio developer, the good old SOAP Web Service was more stable and easy to use.
In fact, no other development tool except Visual Studio could generate a web service client from a SOAP WSDL definition. All other dev tools were overwhelmed ... Microsoft had to react to this fact and take a "more open" path, so that developers can use other tools to use their web service interfaces too.
Now thats the result: Swagger IO, oh my god... Totally out of control :-(