StatusCode: 400, ReasonPhrase: 'Bad Request' - calling addCustomer web api via app

Ying Kit Li 1 Reputation point
2021-11-17T13:46:13.643+00:00

I have faced a connection error to azure from my developing xamarion forms app after I tried to add an email function of google SMTP to the app. I used my own google account's credentials to send email and allow Less Secure Apps in google account setting. However, after I successfully sent the first email, Google blocked the app and surprisingly azure also could not get the uploaded data from the app. I started the debug mode in visual studio and got the following messages:

{StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Date: Wed, 17 Nov 2021 12:30:01 GMT
Server: Microsoft-IIS/10.0
Set-Cookie: ARRAffinity=ee7a1ed55adb83304d202ee1fe723b7adba7ac178c79e64e7f03ca620a2fd2b7;Path=/;HttpOnly;Secure;Domain=datingbirdapi.azurewebsites.net
Set-Cookie: ARRAffinitySameSite=ee7a1ed55adb83304d202ee1fe723b7adba7ac178c79e64e7f03ca620a2fd2b7;Path=/;HttpOnly;SameSite=None;Secure;Domain=datingbirdapi.azurewebsites.net
X-Android-Received-Millis: 1637152201237
X-Android-Response-Source: NETWORK 400
X-Android-Selected-Protocol: http/1.1
X-Android-Sent-Millis: 1637152201171
X-Powered-By: ASP.NET
Content-Length: 321
Content-Type: application/problem+json; charset=utf-8
}}

I finally made the email work by setting app password in google. But the azure cloud still cannot get data from my app.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,157 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
293 questions
{count} votes

2 answers

Sort by: Most helpful
  1. AgaveJoe 26,191 Reputation points
    2021-11-17T16:41:38.16+00:00

    Still, you did not provide enough information. We can only guess what you're doing wrong. You've configured an attribute route as /addCustomer. We cannot see the value of AppResources.CustomerUrl. Does AppResources.CustomerUrl = "addCustomer"???

    I don't understand why you have two different models... Did you start having problems after updating the model???? If so, then I assume the client and service model are out of sync.

    0 comments No comments

  2. Ying Kit Li 1 Reputation point
    2021-11-18T11:28:11.173+00:00

    I fount that I delete the customer_id from the todoItem model while missing to delete that in customer model, that cause the out sync problem.

    0 comments No comments