小编Moh*_*nem的帖子

调用 PayU Rest api(创建订单)返回 html 而不是 json 响应

我正在尝试使用 Post Man 等 Rest 客户端工具向 PayU 支付网关发布订单,我也遇到了同样的问题。

在此输入图像描述

我尝试使用 C# 发布,订单创建成功,但响应不符合预期,它应该是一个 json 对象,包含插入的订单 id 和重定向 url ,但当前是 html 响应!

C# 代码响应: 在此输入图像描述

我使用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# 代码 …

c# rest payu payumoney

7
推荐指数
2
解决办法
2101
查看次数

keycloak不适用于MVC5网络应用程序

我正在尝试将我的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)

c# asp.net-mvc-5 keycloak

3
推荐指数
1
解决办法
1946
查看次数

标签 统计

c# ×2

asp.net-mvc-5 ×1

keycloak ×1

payu ×1

payumoney ×1

rest ×1