My Web API method returns string and I am trying to use that string in Angular application. I use swagger and have no issues from Web API side. It is showing string in Swagger
[HttpPut]
[Route("UpdateUserStatus")]
[ProducesResponseType(typeof(string), StatusCodes.Status200OK)]
public async Task<IActionResult> UpdateUserStatus(User user)
{
string userUpdated = await _userService.UpdateUserStatus(user);
return Ok(userUpdated );
}
I am trying to access this string in angular. Service returns like this
public UpdateUserStatus(user: User): Observable<any> {
const url = this._url + 'UpdateUserStatus';
return this._httpClient.put<any>(url, user);
}
this._service
.UpdateUserStatus(this.User)
.subscribe((response: any) => {
this._notificationService.info(
response, //this is not working
'User updated'
);
}, (error) => {
this._rapNotificationService.error(
'Update Failed. ',
'Failed'
);
});
It is giving "http failure during parsing for string" error.