Angularjs - equal sign in $http post data

纵然是瞬间 提交于 2019-12-05 21:38:44

I always use JSON.Stringify() for my POST payloads.

It had to do with URI encoding. The string that was getting getting sent the the lower level AJAX API was not uri encoded. This means that when it saw the = sign in the post it was parsing it assuming uri encoding.

All of the information may not have been present to answer this question as JSONRequest was originally was defined on the line above var request. Sorry about that. It was defined as follows:

var JSONRequest = {
    'JSON': requestObject;
}

where requestObject was

{
    'text':'this is = some text'
}

I ended up URI encoding the JSON Request as follows

var JSONRequest = 'JSON=' + encodeURIComponent(JSON.stringify(requestObject));

This fixed the problem and made my API calls more robust to the HTTP protocol.

Thanks for all the help!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!