Bogdan Constantin Bogdan Constantin - 1 month ago 9
HTTP Question

AngularJS post request. Character changed from initial value

I have this very strange problem. I have a very long string as a token for an app. When i`m doing the http post request, the string changes.

From the ending of "Vow== 256220" it is changing to "Vow: = 256220" and i do not understand why.

Here is the code if helps:

var request = $http({
method: "post",
url: urlWS,
data: {token: token},0

headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
request.success(function (data) {
alert(data);
});

Answer

Following code working for me.

 $http({
        method: "post",
        url: urlWS,
        data: 'token='+encodeURIComponent("Vow== 256220"),
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    });
    request.success(function (data) {
        alert(data);
    });

May be above solution solve your problem.

Comments