Android Question HTTP POST call error

ThePuiu

Active Member
Licensed User
Longtime User
I've used this code on other occasions and it worked, now I've been trying to figure it out for a day and I can't.
B4X:
Dim values As Map = CreateMap("aidi": Main.idFirmaCurenta)
 
    Dim JSONGenerator As JSONGenerator
    JSONGenerator.Initialize(values)

    
    Dim j As HttpJob
    j.Initialize("",Me)
    
    Dim encodedValues As String = UrlEncodeMap(values)
    Log(encodedValues)
    
    j.PostString("http://api.mysite.eu/api/togglefirma",encodedValues)
    j.GetRequest.SetHeader("Authorization","Bearer " & Main.Token)
    j.GetRequest.SetContentType("application/x-www-form-urlencoded")
    
    wait for (j) JobDone(job As HttpJob)
    If job.Success Then
        Log('OK')       
    Else
        Log(job.ErrorMessage)       
    End If

error is: {"Message":"No HTTP resource was found that matches the request URI 'http://api.mysite.eu/api/togglefirma'."}


The API works, an image from Postman is attached
 

Attachments

  • Untitled.png
    Untitled.png
    35.6 KB · Views: 72
  • Untitled2.png
    Untitled2.png
    17 KB · Views: 73

ThePuiu

Active Member
Licensed User
Longtime User
B4X:
curl --location --request POST 'http://api.mysite.eu/api/togglefirma?aidi=99f40fbc-c3f6-4859-9e96-3aa2c5272199' \
--header 'Cookie: .AspNet.Cookies=605_5XAVmPzqzqUeuR2P5SOswvbs2LiczthCzlxZBoPo2Zd3i8K4cGTKhmsDsyrkcVu3TKZNyHVAo6wZ3V9UwB3bHx2-JG_cA7eFTJbO63CNnuwQaPUEudDzdKomMHuygwyM6cPNloeZQQUr3mOBKSJ-UBA5q3dB-KNyBdKN9oa_xAHddsIhOtCZrG1QPu60c-zf5Mb9czB9JPSaaocXveiCucxjdwFeWDZXkJl454-ErXyOCDpnWIiK-glmPZCqLzxGyTebs8Nh8TgguVdPUDQyRrVfvyOxw_SSAwXjxp_pXF-IFAK0rYaOBWNTzjkSst9Qb0gZgn-_GT6FFJNuuJTW7FmJq2eJxX58acyUwqwcmjPhrFRnEaEc1erHKzI8ARz0lxLesS9nSGQpLJc7L4Udcd6zJCtrwAwLQzVYN8iH4svH660pYb6T_CoCdv0VQEImrV1aAO5YZZAjxrpF4VGZeLwb1coq_JjYuYiQBxF90qz0__eTbq8Y1kTAOEieutOgyDe2kiauDgb1WU7ANg' \
--data-raw ''

Same error with PostMultipart: {"Message":"No HTTP resource was found that matches the request URI 'http://api.mysite.eu/api/togglefirma'."}
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
I tried this, but without luck:
B4X:
j.PostString("http://api.mysite.eu/api/togglefirma", "aidi=" & Main.idFirmaCurenta)


I don't know why cookie is there...today it is missing!
B4X:
curl --location --request POST 'http://api.mysite.eu/api/togglefirma?aidi=99f40fbc-c3f6-4859-9e96-3aa2c5272199' \
--data-raw ''


To make things easier, we've removed token authentication from the POST call. But nothing has changed ...
 
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
no, I don't have documentation ... the API is made by me using ASP.NET. For this reason I used Postman to check that it was working properly. Unfortunately, I can't make the real API address public here.

I tried to change the way I send the parameters in Postman as in the attached image and I managed to simulate the error. But I don't know what to change in B4A ...
Untitled3.png
 
Upvote 0
Top