I'm interested in writing a client library for the NuGet v3 API in a non-.NET language.
What are the requests required to get a package, and what does the response looks like?
i.e.
GET {package-versions}
GET {package-version}
Can you also link to the official documentation that covers this scenario?
Here is the official NuGet V3 API documentation. The API is composed of multiple protocols, including:
The PackageBaseAddress - The store that contains the actual packages and their manifest files (the nuspec).
The Service Index - used by the client to discover the NuGet services
The Search Service - used by clients to search for NuGet packages
The Registration - A json-LD based structure that stores the packages' metadata. This includes packages' content, dependencies, descriptions, etc...
For example, say you wanted to download the package "Newtonsoft.
Json":
Get the service index: `GET https://api.nuget.org/v3/index.json
The response contains the address of the PackageBaseAddress (aka, incorrectly as the flat container, as it is hierarchical and not flat :) ):
{
"#id": "https://api.nuget.org/v3-flatcontainer/",
"#type": "PackageBaseAddress/3.0.0",
"comment": "Base URL of Azure storage where NuGet package registration info for DNX is stored, in the format https://api.nuget.org/v3-flatcontainer/{id-lower}/{version-lower}.{version-lower}.nupkg"
},
Use the uri provided by the #id as a base uri to list the versions of the desired package: GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json, note that this uri is subject to change and is not part of the API
Use the same base uri to download a package: GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/6.0.4/newtonsoft.json.6.0.4.nupkg
You may also want to look at the NuGet client. The client's source code is
here; you'll want to start from the NuGet.CommandLine project and walk your way down the stack.
Related
I feel I must be missing something obvious here. I've been trying to follow the instructions at https://learn.microsoft.com/en-us/bing/search-apis/bing-visual-search/quickstarts/sdk/visual-search-client-library-csharp. I created a "Bing Search" service in Azure with the S9 tier which supports Visual Search. I went to the Keys and Endpoint section and copied the Key 1 out and put it in the below code, yet every time I run it I get Unauthorized:
{"code":"401","message": "Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource."}
var client = new VisualSearchClient(new Microsoft.Azure.CognitiveServices.Search.VisualSearch.ApiKeyServiceClientCredentials("<key>"));
ImageInfo ImageInfo = new ImageInfo(url: "https://media.vanityfair.com/photos/5d9f5be40fa2040008f28470/4:3/w_1776,h_1332,c_limit/always-sunny-in-philadelphia-hangs-in-there.jpg");
VisualSearchRequest VisualSearchRequest = new VisualSearchRequest(imageInfo: ImageInfo);
var result = await client.Images.VisualSearchMethodAsync(knowledgeRequest: JsonConvert.SerializeObject(VisualSearchRequest));
The instructions don't say anything about setting an endpoint, but I tried that too, setting the Endpoint property from the one in my Keys and Endpoint page:
client.Endpoint = "https://api.bing.microsoft.com/";
But that just result in a NotFound error.
Anyone have any idea what's going on? I tried both keys with no success. Here's a LINQPad repro of the issue: http://share.linqpad.net/c3p8vo.linq
Thanks!
I figured out the issue. The documentation is actually wrong (as of 8/9/22). It says
The NuGet Visual Search package.
From the Solution Explorer in Visual Studio, right-click on your project and select Manage NuGet Packages from the menu. Install the Microsoft.Azure.CognitiveServices.Search.VisualSearch package.
But that's the old nuget package, which has the old endpoint in it: https://api.cognitive.microsoft.com. The new endpoint is https://api.bing.microsoft.com. I found that there's actually another, newer nuget package, Microsoft.Bing.Search.VisualSearch which has the correct endpoint, but I can't find documentation anywhere pointing to it!
Once I switched to that nuget package though, everything worked as expected when passing an imageUrl. I still can't get it to work with a FileStream though, I think that might be broken as well.
I try to encapsule our PowerBI Server REST API via the PowerBI Client NuGet Package from Microsoft.
I ran into the problem that the URI gets a wrong relative path added.
The REST API of our Reporting Server (on-premise) has a base URI like: https://niceReportingURL.com/reports/api/v2.0 but the NuGet package adds another "/v1.0/myorg" to the URI, which is not necessary.
So resulting of that, the request URI looks like this: https://niceReportingURL.com/reports/api/v2.0/v1.0/myorg
I saw in the source code of the class "ReportsOperations" that this weird relative URI gets added hardcoded!
string uriString = new Uri(new Uri(absoluteUri + (absoluteUri.EndsWith("/") ? "" : "/")), "v1.0/myorg/reports").ToString();
I omitted the "/Reports" in my example URIs because it looks like a general problem.
Is there an option or workaround that the NuGet Package doesn't add this relative URI?
The request looks like this:
var c = new BasicAuthenticationCredentials
{
UserName = "reportingUser",
Password = "secretReportingPW"
};
var client = new PowerBIClient(new Uri("https://niceReportingURL.com/reports/api/v2.0"), c);
var result = await client.Reports.GetReportsAsync().ConfigureAwait(false); // Here comes the fail
The PowerBI Client package encapsulates access to the PowerBI REST API.
This API is distinct from the Reporting Services REST API, which appears to have no ready-made NuGet package that encapsulates it, but does have an OpenAPI specification that makes it easy to use.
Both APIs have endpoints for retrieving reports, but they're different kinds of report. Confusingly, Microsoft has chosen to rebrand Reporting Services as "paginated reports" in the PowerBI ecosystem, so at least some Reporting Services reports can be retrieved using the PowerBI REST API. For reports hosted by an on-premise Reporting Services instance, though, you want the Reporting Services API and can't use the PowerBI REST API.
Using the TFS2018 api is it possible to retrieve all solution files related to a specific build?
First, you need to use Get a build api to get the sourceVersion of this build:
GET http://TFS2018:8080/tfs/DefaultCollection/{project}/_apis/build/builds/{buildId}?api-version=2.0
Then, you have two choices to retrieve all files that the build use:
Use tf get command.
Use REST API to download a zip folder for the sources. The api is as below:
~
GET http://TFS2018:8080/tfs/DefaultCollection/_api/_versioncontrol/itemContentZipped?path={FolderPath}&version={sourceVersion}
Also you may try (for git):
Set "Tag sources on success" for build definition.
Get sources with tag through tfs rest api: Get a specific version
I have a directory which hosts my web services based on ServiceStack. Inside the directory I have a help folder which has some html pages in it. However when I try browse to those pages, ServiceStack thinks that I am trying to hit a route and gives me "Handler for Request not found".
Is there any way to tell ServiceStack to ignore certain routes? If a route matches a directory present in IIS surely it can't be a service route?
http://www.example.com/exampleservice/metadata <-- fine
http://www.example.com/exampleservice/help/main.html <-- has nothing to do with ServiceStack as it's a directory
This looks to have been nicely implemented in ServiceStack v4. Demis posted about it here.
The Virtual FileSystem is now fully integrated into the rest of ServiceStack, this enables a few interesting things:
The Config.WebHostPhysicalPath sets where you want physical files in ServiceStack to be serve from
You can now access static files when ServiceStack is mounted at a custom path, e.g. /api/default.html will serve the static file at ~/default.html
By Default, ServiceStack falls back (i.e when no physical file exists) to looking for Embedded Resource Files inside dlls.
You can specify the number and precedence of which Assemblies it looks at with Config.EmbeddedResourceSources which by default looks at:
The assembly that contains your AppHost
ServiceStack.dll
I havent worked with that Salesforce API before, so I am a bit stuck on how to connect to the salesforce service.
So far I understood that I have to generate a wsdl file for my account or rather the account of my customer (step 1). So far, so good.
But now the Quickstart (http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_quickstart_steps.htm) says something about "Import the WSDL File into your development platform" (step 2).
How do I import a wsdl file into Visual Studio 2008? I cant find the "Add Web Reference" option which is mentioned in the quickstart.
And if I only need to use the WSDL, what use has the Salesforce Dotnet API package which can be downloaded from the salesforce website
(http://wiki.developerforce.com/index.php/Salesforce_Dotnet_API)?
Are there any gotchas I should watch out for when developing applications that use the salesforce API?
If you follow the directions in Binz' answer, you should be able to add a web service reference using Visual Studio.
The "Salesforce Dotnet API package" on the wiki site is not required to access the SalesForce API, it's just a library that tries to abstract it.
As far as gotchas and other things to know, I would recommend that you read chapter 6 of the Force.com Cookbook. You have to sign up for a force.com developer account (free). Most of the things you'll need to be aware of are covered in this chapter. Here are a few of them:
logging in / logging out - session
management
query / queryMore pattern (needed if
you're going to pull large sets of
data from SalesForce)
how to construct a wrapper class -
there is some sample vb.net code you
can download as well
One other thing to note, if you're going to use SOQL to query your SalesForce data, and you need to filter on a SalesForce date field, you'll need to format the date string. Here's one way to do it:
public static string FormatDateForQuery(DateTime dateToFormat, bool includeTime)
{
if (includeTime)
{
return dateToFormat.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ss+00:00");
}
else
{
return dateToFormat.ToUniversalTime().ToString("yyyy-MM-dd");
}
}
For Visual Studio 2008 you need to select 'Add Service Reference', then click the 'Advanced' button on the bottom left of the dialogue. There should then be a button on the bottom of that dialogue that says 'Add Web Reference'. You should be able to then select your wsdl file and a service client proxy will be auto genned for you by VS.
To create the WSDL file, go to (your name, top right), set up, develop > api > generate enterprise wsdl > generate. In Chrome, click save page as and put that file in the c drive. In Visual Studio, go to add service reference > advanced > add web reference. Point to the file you downloaded: file:///c:/wsdl.jsp.xml
There is a parsing issue when using .NET 2.0 with date time fields in salesforce, accessing through web services.
It seems to be a bug in .NET but there's another way to address it by manually editing the wsdl.
More information here:
http://community.salesforce.com/t5/NET-Development/Can-t-update-date-datetime-from-c-webservice-through-enterprise/m-p/96046