Android Question Error at calling API

ThePuiu

Active Member
Licensed User
Longtime User
I'm trying to make a call to an API (MVC). From the Postman application the call is made correctly, the received data being correct. If I try to make the same call from the B4A application, I get an error message: ResponseError. Reason: Not Found, Response: {"Message": "No HTTP resource was found that matches the request URI 'http://builders.test.com/api/Mobile'."}
The code is:
B4X:
Dim jobDownload As HttpJob
jobDownload.Initialize("jobLoad", Me)
jobDownload.PostString("http://builders.test.com/api/Mobile", "aidiUser=" & userId & "&Tipe=1")
jobDownload.GetRequest.SetHeader("Authorization", "Bearer " & Token)
jobDownload.GetRequest.SetHeader("Accept", "application/json")

Wait For (jobDownload) JobDone(j As HttpJob)
If j.Success Then
................
Else
    MsgboxAsync(jobDownload.ErrorMessage,"jobLoad")    <---------- message
End If
jobDownload.Release()


In the attached image is a printscreen from Postman in which you can see the parameters with which the API responds correctly. What am I not doing well?
 

Attachments

  • postman.png
    postman.png
    15 KB · Views: 150

JohnC

Expert
Licensed User
Longtime User
Assuming you have added the line to the manifest to allow HTTP connections...

I noticed that the tab says "Headers (7)" (6 are hidden), but you are not providing all 7 headers. Maybe that's the cause?

Also, you did a good job of replacing all the references to the real URL with "test.com" (for security reasons), because even the image has "test.com" in it. So I just want to make sure that the real url is not "test.com" because if your code is truly trying to use test.com, then that would definitely be the reason why it's failing because I don't think that's the domain you want to be using.
 
Last edited:
Upvote 0

ThePuiu

Active Member
Licensed User
Longtime User
In manifest file I added: CreateResourceFromFile(Macro, Core.NetworkClearText)
No, domain is not test.com. I've change the name just for security reasons.
The other keys in the Header are in the attached image. I deselected one by one until the call stopped.
 

Attachments

  • postman.png
    postman.png
    12.9 KB · Views: 129
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I'm out of ideas of what could be causing the problem.
 
Upvote 0
Top