I currently have this section in a function of an Ionic application that uses Angular and Capacitor. The function is for uploading a file using a FormData post.
var data = new FormData();
data.append(name, blobFile, "TestName");
data.append('fileId', params.fileId);
data.append('pagenumber', params.pageNum);
data.append('appid', this.appMod.appId);
data.append('sessionid', this.appMod.sessionId);
...
return this.http.post(
webServiceUrl,
data,
{headers: new HttpHeaders({'Content-Type': undefined})},
);
With this.http
being the Angular HttpClient
. When this section runs, it reaches the http.post
however what is returned is the following error
SyntaxError: Unexpected token o in JSON at position 1
Checking network activity, this post never actually sends out any network requests leading me to believe this is not an issue with the backend
From what we have tested we tried setting 'Content-Type': 'application/x-www-form-urlencoded'
and adding responseType: 'text'
in the HttpOptions however both did not fix the issue. In addition I have repeatedly made sure that the webServiceUrl
is correct.
I have no idea what could be causing this issue so any insight will be helpful