Android Question XMLHttpRequest

mw71

Active Member
Licensed User
Longtime User
Hello,

I would like to send data to a website (its not mine Site).
I see (with Network Tool from Firefox/EDGE) that the data is sent as JSON with a POST request. Initiator means XMLHttpRequest.

How can I make an XMLHttpRequest? (I think it's not the same as a "normal" HttpRequest with the OKHttp-Lib?)

Many Thanks
 

DonManfred

Expert
Licensed User
Longtime User
I see (with Network Tool from Firefox/EDGE) that the data is sent as JSON with a POST request
you can use okhttputils for this.

Which api are you accessing?
 
Upvote 0

mw71

Active Member
Licensed User
Longtime User
hi,

The page does not have a documented API.
There is a Form, made as Table, with an Submit Button:
HTML:
<button type="button" ng-click="submitSpot()" class="btn-share btn btn-success">Share</button>

I think, but i'm not sure, that the Button work with Javasript.
 
Upvote 0

mw71

Active Member
Licensed User
Longtime User
if i found the correct JS and Position:
B4X:
b.submitSpot=function(){if(j.defer().resolve(),
b.spotsLoading=!1,
!(void 0===b.newSpot||void 0===b.newSpot.de_call||void 0===b.newSpot.dx_call||void 0===b.newSpot.frequency||b.newSpot.de_call.length<1||b.newSpot.dx_call.length<1||b.newSpot.frequency.length<1))
{if(b.newSpot.info&&"undefined"!==b.newSpot.info||(b.newSpot.info=""),
parseFloat(b.newSpot.frequency.replace(",","."))<100)
{var a=parseFloat(b.newSpot.frequency.replace(",","").replace(".",""))+"";b.newSpot.frequency=a}
c({method:"POST",data:b.newSpot,url:Endpoints.spots}).success(function(a)
{"ok"===a.status?(b.newSpot.dx_call="",b.newSpot.frequency="",b.newSpot.info="",
window.alert("New spot submitted")):window.alert(a.status)}).error(function(){window.alert("Error")})}}

url:Endpoints.spots -> Endpoints={spots:baseUrl+"/api/v1/spots"......

sri for the missing formatting, I'm not familiar with JS.
 
Upvote 0

mw71

Active Member
Licensed User
Longtime User
i add the follow Code:
h_spot.GetRequest.SetContentType("application/json;charset=UTF-8")
:confused:

Now it seems to work.
 
Upvote 0
Top