Hello,
I created a c# application that is attempting to use the AEM API to upload assets into our AEM As a Cloud Service instance. I am able to use the API to generate a valid token, but whenever I try to call any AEM APIs with that token, I always get a 401 - Unauthorized response. If I use the same url and token in Postman, it works everytime. Here is my code for reference:
using (var lClient = new HttpClient())
{
var lRequestContent = new MultipartFormDataContent();
lRequestContent.Add(new StringContent(pFileName), "fileName");
lRequestContent.Add(new StringContent(pFile.Length.ToString()), "fileSize");
lClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", pToken);
var lResponse = lClient.PostAsync($"{BaseUrl}/{BaseFolderPath}.initiateUpload.json", lRequestContent).Result;
}
Has anyone experienced this before, and if so, do you have any advice you would be willing to share?