Azure API Management - Versioning path schema duplicates version in url - asp.net-core-webapi

I'm trying to apply api management version sets to query a .Netcore 3.1 web api which has two versions. I have chosen the path schema on the version set, which appends the version identifier to the url. In this case /v1:
The thing is that in my api I am also using path schema to version the endpoint on the web api, so when apim builds the url, it appends the apim version identifier to the api version path, which results in a duplicate, like:
https://myapi.com/apiname/v1/v1/endpoint , where v1/endopoint is the path to the controller.
To solve this, I have switched the version schema on the web api to header and created a policy on apim that adds the version header to the request, so that the only version in the path is now the one in apim.
I wanted to know if this is the right way to go or if there is a better solution. Maybe its possible to tell apim to ignore the version /v1 from the path?
Thanks for the help!

APIMs domain model allows one to control versioning scheme (path prefix, header name/value, query parameter name/value) at the level of API version set, so that you do not need to duplicate /v1.0 on every operation of your API. By nature of this if your API version set is configured to have path prefix of /v1.0 it will be appended to all API paths included into this version set. And that is what produces the doubling.

Related

How to define firebase-remote-config parameters based on app version

I need to distribute some settings based on the app version e.g. if app version equals "4.0.1" then a else b. I found the possibility to define a condition named "version" but the documentation says it is bound to the package name of the app and not the version or version code.
see here https://firebase.google.com/docs/remote-config/parameters
I tried it though specifying the app version through a "version" condition but it does not work. Any ideas on this would be much appreciated.
The main problem is that Remote config's "Version" is the build number and not the actual version number.
The way I found around this is you can add a "User Property" in Firebase like "app_version". Then when the app launches add the following code:
let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
Analytics.setUserProperty(version, forName: "app_version")
You can then use this User Property in Remote Config as a condition and voila you can base some Remote Config value of of the version number. Note this will require the use of Firebase Analytics as well.
Creating a condition, which targets an app version via regular expression appears to be the only solution in this case.
For my app I use the following configuration:
Here, users who have versions 1.8.* and below receive an alternate version of a backend configuration parameter.
If you need to target only a specific version of the app, then a regular expression is not really necessary, so the approach that you took should work.
Alternatively, you can have far more control if you create a user audience based on app version, and then target the audience.

Change repository name in Alfresco

Does anyone know how to set/change a repository name in alfresco?
id=-default-, name=, description=, capabilities=Repository Capabilities
The Alfresco CMIS calls started returning an empty string for name sometime around 5.0, I believe. According to the spec, the name is not a required piece of information. The server is required to return a unique ID for each repository in the system, but that's it.
I do not believe you can change the name without touching Alfresco CMIS implementation Java classes.
Besides, Alfresco only supports a single repository so a name isn't going to add a lot of value.

SBT credentials file with multiple realm

We run an artifactory server, that has moved to a different endpoint (artifactory-b.example.com). To make it backwards compatible, the old url (artifactory-a.example.com) is being proxied to the new one.
However, publishing with sbt uses a .ivy2/.credentials file with the following layout
realm=Artfactory realm
host=artifactory-a.example.com
user=artifactory-user
password=P4ssw0rdH4sh
however, I would like to change this so new builds will publish to the correct endpoint
realm=Artfactory realm
host=artifactory-d.example.com
user=artifactory-user
password=P4ssw0rdH4sh
Is it possible to add multiple realms in one file? That sbt will try the first, if it does not work (Forbidden|Not Found) the second? So that my .ivy2/.credentials file looks like
# old instance for backwards compatibility
realm=Artfactory realm
host=artifactory-a.example.com
user=artifactory-user
password=P4ssw0rdH4sh
# New spiffy instance
realm=Artfactory realm
host=artifactory-b.example.com
user=artifactory-user
password=P4ssw0rdH4sh
Anyone any experience with this, or am I bound to using two files, and change the reference in my repo to the second file (i.e. .ivy2/.credentials2).
P.S. The realms are in a file, because multiple repos use these credentials to publish.
So important here is that the realms have the same name, only a different endpoint (unlike this post):
May there is no way to have multiple realms within a credential file, but you could have multiple realms within multiple credential files, each realm in a separate credential file.
In ~/.ivy/.credentials will be:
realm=Sonatype Nexus Repository Manager
host=mvn.nexus1.org
user=readonly
password=readonlyPass
And in ~/.ivy/.credentials.deploy will be:
realm=Sonatype Nexus Repository Manager
host=deploy.nexus2.org
user=deployment
password=deploymentPass
So then you will have these lines in your build.sbt:
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
credentials += Credentials(Path.userHome / ".ivy2" / ".credentials.deploy")
Turns out that what I want is not possible using a properties file, because that is just not how property files work.
Maybe there is another way, but the solution I want can not be achieved in this way, unfortunately

Google Drive API - Example code is not working

I want to use Google API to transfer SharePoint Documents to Google Drive using dot net. For that to happen I want to use this link Google Quick Start.
I have followed every little piece of information. It states in beginning "Complete the steps described in the rest of this page, and in about five minutes you'll have a simple Drive app that uploads a file to Google Drive" but it is not true.
I am trying to run this sample example since yesterday but failed.
// Register the authenticator and create the service
var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, CLIENT_ID, CLIENT_SECRET);
var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);
So it seems that this code example is outdated and Google APIs have been upgraded.
Here comes the warning
[Obsolete("GoogleAuthenticationServer is not supported any more and it's going to be removed in 1.7.0-beta. Consider using the new Google.Apis.Auth NuGet package which supports .NET 4, .NET for Windows Store apps, Windows Phone 7.5 and 8 and Portable Class Libraries as well")]
Another code
var service = new DriveService(new BaseClientService.Initializer()
{
Authenticator = auth
});
And the error
Cannot implicitly convert type 'Google.Apis.Authentication.OAuth2.DotNetOpenAuth.NativeApplicationClient' to 'Google.Apis.Http.IConfigurableHttpClientInitializer'. An explicit conversion exists (are you missing a cast?)
Then I was looking for [latest release samples] there I found the source files.
I was not able able to run the sample also.
Here I was successfully authenticated but then had error for redirect Uri
My Client_Secrets.JSON looks like, as you can see I have set default redirect Uri to http://localhost/.
{"web":{"auth_uri":"https://accounts.google.com/o/oauth2/auth","client_secret":"secret","token_uri":"https://accounts.google.com/o/oauth2/token","client_email":email","redirect_uris":["http://localhost/"],"client_x509_cert_url":"aa#developer.gserviceaccount.com","client_id":"id","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","javascript_origins":["http://localhost:53404/"]}}
Now I can run this application but as mentioned getting error
Error: redirect_uri_mismatch
The redirect URI in the request: [[http://localhost:2430/authorize/]] did not match a registered redirect URI
I really don’t know from where this port number comes and from where this authorize comes. As you can see in my JSON, I have not set anything similar.
I am using VS 2010 SP1 Ultimate and Windows 7 home Basic.
I have tried to give complete information and my end goal is upload document in Google drive.
The tutorial you are following uses an older version of google.apis thats why you are seeing the not supported. Here are a couple of tutorials on how it works with the new version of the api.
http://daimto.com/google-oauth2-csharp/
http://daimto.com/google-drive-api-c/
Take a look in https://code.google.com/p/google-api-dotnet-client/source/browse/Tasks.ASP.NET.SimpleOAuth2/Default.aspx.cs?repo=samples. It's a Task API ASP.NET sample. As you can see you need to add several lines of code, but it works.
I downloaded the samples Eyal mentions and got that compiling before integrating with my own app. .Net needs to be 4 although it states it supports higher.
You have to set the redirect URI in the google developer console, not in your JSON. In your case, you would want to set it to http://localhost:2430/authorize/.

IIS Express denying PUT requests in ADO.Net data services

I have a project that uses ado.net dataservices. This project was originally developed in VS2005 and IIS6 but I am now porting it to IIS7 standards. I've run into a snag when trying to update existing records, the put operation (to the service) fails and prompts the following browser alert:
The URI 'http://localhost:6188/services/Datatracker.svc/provider' is not valid for PUT operation. The URI must point to a single resource for PUT opeations.
I imagine this is because the URI is being treated as a folder, and I know that this can be corrected through configuration but I'm having trouble finding the specific settings
Any assistance would be appreciated.
So as it turns out this is invalid syntax for put and delete requests:
http://localhost:6188/services/Datatracker.svc/provider
Valid odata syntax is: (OLKM represents the calue of the keyfield that uniquely identifies the record)
http://localhost:6188/services/Datatracker.svc/provider('OLKM')
Old asp.net + iis6 allowed you to cheat your way around this requirement, but iis7 & .net 3.5+ requires you to use the correct syntax.

Resources