I was able to make it work by following the answer Jagjeet Singh Makhija in the following link https://learn.microsoft.com/en-us/answers/questions/363643/web-activity-gives-error-code-2108-but-same-api-ca
Using that cookie as Header and passing the value from previous webactivity, make the unauthorized error go away and I was able to write it back to api.