我正在尝试使用 Post Man 等 Rest 客户端工具向 PayU 支付网关发布订单,我也遇到了同样的问题。
我尝试使用 C# 发布,订单创建成功,但响应不符合预期,它应该是一个 json 对象,包含插入的订单 id 和重定向 url ,但当前是 html 响应!
我使用restsharp库的C#代码:
public IRestResponse<CreateOrderResponseDTO> CreateOrder(CreateOrderDTO orderToCreate)
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var actionUrl = "/api/v2_1/orders/";
var client = new RestClient(_baseUrl);
var request = new RestRequest(actionUrl, Method.POST)
{
RequestFormat = DataFormat.Json
};
request.AddJsonBody(orderToCreate);
request.AddHeader("authorization", $"Bearer {_accessToken}");
request.AddHeader("Content-Type", "application/json");
var response = client.Execute<CreateOrderResponseDTO>(request);
if (response.StatusCode == HttpStatusCode.OK)
{
return response;
}
throw new Exception("order not inserted check the data.");
}
Run Code Online (Sandbox Code Playgroud)
我使用内置的 C# 代码 …
我正在尝试将我的MVC5 Web应用程序与Keycloak服务器v1.98连接.它是连接的.当我访问我的网络应用程序时,Keycloak需要输入凭据,当我输入凭据时,我得到以下异常:
我的配置(startup.cs):
public void Configuration(IAppBuilder app)
{
const string persistentAuthType = "WebApplication1_cookie_auth";
// --- Cookie Authentication Middleware - Persists user sessions between requests
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = persistentAuthType
});
app.SetDefaultSignInAsAuthenticationType(persistentAuthType); // Cookie is primary session store
// --- Keycloak Authentication Middleware - Connects to central Keycloak database
app.UseKeycloakAuthentication(new KeycloakAuthenticationOptions
{
// App-Specific Settings
ClientId = "dotnettest", // *Required*
VirtualDirectory = "", // Set this if you use a virtual directory when deploying to IIS
// Instance-Specific Settings
Realm …Run Code Online (Sandbox Code Playgroud)