Skip to main content
Solved

REST API Programming: Login Error

  • Aug 28, 2025 4:25 PM UTC
  • 5 replies
  • 125 views
  • Translate All

Hey everyone! New to acumatica REST API. Getting this error when trying to simply login using the HTTPClient in MS visual studio:

StatusCode: 415, ReasonPhrase: 'Unsupported Media Type', Version: 1.1, Content: System.Net.Http.StreamContent

Grateful for any assist on this.

Thanks!

Best answer by Dmitrii Naumov

​@alandgates it seems you do not convert your logindata to JSON properly

 

Should be like that:

Dim json As String = JsonSerializer.Serialize(logindata)

Dim content As New StringContent(json, Encoding.UTF8, "application/json")

View original

5 replies

Dmitrii Naumov
Community Manager
Forum|alt.badge.img+7

​@alandgates please add the code to review.

Seems like you send the boy with a wrong content type. It should be application/json

Translate

  • Author
  • Freshman II
  • Aug 28, 2025 4:50 PM UTC

of course! Though when I add it, now I get a different error.

Code:

            Dim logindata As New Dictionary(Of String, String) From {{"name", "testuser"}, {"password", "Hello1234!"}}
            Dim content As New StringContent(logindata.ToString, Encoding.UTF8, "application/json")
New error:

StatusCode: 400, ReasonPhrase: 'Bad Request'

I suspect that this means I have the json incorrectly formatted.

Translate

JSpikowski
Jr Varsity II
Forum|alt.badge.img
  • Jr Varsity II
  • Aug 28, 2025 6:31 PM UTC

How are you handling cookies and auth?

Translate

Dmitrii Naumov
Community Manager
Forum|alt.badge.img+7
  • Community Manager
  • Answer
  • Aug 28, 2025 7:04 PM UTC

​@alandgates it seems you do not convert your logindata to JSON properly

 

Should be like that:

Dim json As String = JsonSerializer.Serialize(logindata)

Dim content As New StringContent(json, Encoding.UTF8, "application/json")

Translate

  • Author
  • Freshman II
  • Aug 28, 2025 7:07 PM UTC

Dmitri,

That was it! Such a basic oversight on my part. Thank you for the additional set of eyes to look at it.

Alan

Translate