POST API ERROR при попадании через приложение для Android

У меня есть приложение для Android, которое попадает в мой api.. ниже - api сообщения о входе в систему... когда я нажимаю api через мое приложение, оно показывает, что что-то пошло не так... и когда я нажимаю api через почтальона..its show не удается обработать... text / xml charset = utf-8 '"error..

Myservice.svc.cs

public WebResponse ValidateUser(WebRequest valid)
    {
         WebResponse objWebResponse = new WebResponse();
         // webRequestdto objData = new webRequestdto();
         //objData = JsonConvert.DeserializeObject<webRequestdto>(valid.data);     

        try
        {           
           var sqlQuery = string.Empty;
           DataTable obj = null;             
           if (!string.IsNullOrEmpty(valid.Username) &&!string.IsNullOrEmpty(valid.Password))
          //if (!string.IsNullOrEmpty(valid.data))
            {
               sqlQuery = @"select gen_users.UserId, gen_users.MobileNo, gen_users.EmailID, concat(Firstname, ' ', Lastname) as FullName from gen_users
                        where gen_users.Username='{0}' and gen_users.UserPassword = reverse('{1}') and gen_users.IsActive='Y'";

                sqlQuery = string.Format(sqlQuery, valid.Username, valid.Password);
                obj = DbHelper.ExecuteDataset(Globals.GetConnectionString(), CommandType.Text, sqlQuery).Tables[0];                   
            }
                if (obj.Rows.Count > 0)
                {                    
                objWebResponse.userid = Convert.ToInt32(obj.Rows[0]["UserId"]);                    
                objWebResponse.EmailID = Convert.ToString(obj.Rows[0]["EmailID"]);
                objWebResponse.FullName = Convert.ToString(obj.Rows[0]["FullName"]);
                objWebResponse.MobileNo = Convert.ToString(obj.Rows[0]["MobileNo"]);
                objWebResponse.status = "success";

                return objWebResponse;
                }
            else
            {
                objWebResponse.status = "fail";
                objWebResponse.userid = 0;
               return objWebResponse;                   
            }
        }
        catch (Exception ex)
        {
         throw new FaultException(ex.Message);
        }
    }

Myservice.cs

[OperationContract]
    [WebInvoke(UriTemplate = "ValidateUser",
    RequestFormat = WebMessageFormat.Json,
    ResponseFormat = WebMessageFormat.Json, Method = "POST")]
    WebResponse ValidateUser(WebRequest valid);

web.config

<?xml version="1.0" encoding="utf-8"?>
    <configuration>

        <appSettings>
            <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
            <add key="*" value="Server=*;Database=*;User ID=*;Password=*;" />
        </appSettings>
        <system.web>
            <compilation debug="true" targetFramework="4.5.2"/>
            <httpRuntime targetFramework="4.5.2"/>
            <httpModules>
                <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
            </httpModules>
        </system.web>
        <system.serviceModel>
            <behaviors>
                <serviceBehaviors>
                    <behavior>
                        <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
                        <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
                        <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                        <serviceDebug includeExceptionDetailInFaults="false"/>
                    </behavior>
                </serviceBehaviors>
            </behaviors>
            <protocolMapping>
                <add binding="basicHttpsBinding" scheme="https"/>
            </protocolMapping>    
            <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
        </system.serviceModel>
        <system.webServer>
            <modules runAllManagedModulesForAllRequests="true">
                <remove name="ApplicationInsightsWebTracking"/>
                <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler"/>
            </modules>

            <directoryBrowse enabled="true"/>
            <validation validateIntegratedModeConfiguration="false"/>
        </system.webServer>

    </configuration>

0 ответов

Другие вопросы по тегам