What does * mean on web api - asp.net-web-api

I am studying Udaru and on Swagger Web API there is * on resource here. i would like to know what does this mean ?

This should be a wildcard. This means that you can call URL such as:
/authorization/access/1/hello/a/b/c/d
And resource variable will then be a/b/c/d in the action method.

Related

How to change route URL in Laravel 9 resource controller

I wondered if there is a way to change the default URLs of Laravel's resource controller. For example, for basic CRUD operation, for creating, we have a /create route made by default by Laravel. Can it be changed to /ask or /new or something like that?
You can "localize" the resource URIs that are created without much work (Added to the boot method of a Service Provider):
Route::resourceVerbs([
'create' => 'new',
]);
This would have all calls to Route::resource(...) create the URI with 'new' instead of 'create' for the create action.
If you need to get more complicated than something like that you could extend Illuminate\Routing\ResourceRegistrar to override it in any way you would like. You could call an instance of your version or bind it to the container for Illuminate\Routing\ResourceRegistrar which would use it for all resource calls.
Laravel 9.x - Docs - Controllers - Resource Controllers - Localizing Resource URIs

Alipay post URL when click on order submit

Which parameters are needed to build a Alipay post URL ?
Currently using https://openapi.alipaydev.com/gateway.do? as a test URL and service is service=create_forex_trade
I think you need to add following parameters
openapi is used for testing purpose while mapi.alipay.net is used for actual transaction purpose
https://openapi.alipaydev.com/gateway.do?_input_charset=utf-8
body={ordernumber}
currency={AUD}
notify_url={notify_url}
out_trade_no={}
partner={partner_id}
price=1395
quantity=1
return_url={return_url}
service=trade_create_by_buyer
sign={encryption_sign_key}
sign_type=MD5

Parameter format issue with ASP.NET Web API controller

I am watching this pluralsight demo video on Web Api, and he is using fiddler to pass in a parameter using Http Get with the syntax of controller/parameter
So he's using http://localhost:2405/api/values/5
5 Is the parameter he's passing in.
In my code, I have everything set up exactly the same way he does... with a routing template of {controller}/{id} and a controller method with a signature of
public string Get(string zipcode)
I can pass a parameter just fine with http://localhost:2405/api/values?zipcode=25252 but if I try passing in a paramter the way he does, like http://localhost:2405/api/values/25252 I get an error saying I do not have an action available to handle that request on the controller.
What is he doing right, that I'm doing wrong?
You need to change your routing template to {controller}/{zipcode} as the name of the parameter must match the name in the template.

Web API get route values

Is there any way to statically get route values from a service method (outside of a controller) that is running in a Web API context? For example, I can do the following in ASP.NET MVC:
var mvcHandler = HttpContext.Current.Handler as MvcHandler;
var routeValues = mvcHandler.RequestContext.RouteData.Values;
I'd like to find the equivalent version of this code for Web API.
When I try to debug a sample Web API request and look at HttpContext.Current.Handler it is of type HttpControllerHandler, but this type doesn't have any properties to access route data.
EDIT
To try to help provide some more information. The code I am trying to read the value from is inside of a factory class I have that builds a custom object for my application.
You can use GetRouteData() extension on HttpRequestMessage. You would need to include System.Net.Http namespace to get this.
System.Web.Http.Routing.IHttpRouteData routeData = Request.GetRouteData();
I was able to find a solution that would get the route values for either an MVC request or a Web API request.
HttpContext.Current.Request.RequestContext.RouteData

Google ajax api

Is it possible to use Google AJAX API :
on local google search engine for example : google.es
or is it only working for google.com?
Thanks for helping.
It is possible, and there are a few ways to do it.
See this entry on Googles AJAX API blog.
There are three possible ways to implement, depending on how you're using the API:
If you use the loader, you can simply load jsapi on the domain you're
interested in (example), such as:
Alternately, you can set this with the web search object's
.setRestriction method (example):
var ws = new google.search.WebSearch();
ws.setRestriction(google.search.Search.RESTRICT_EXTENDED_ARGS,
{'gl' : 'es'});
Finally, if you're using the RESTful interface, all you have to do
is append a "gl" URL parameter to your
request:
http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=flowers&gl=fr

Resources