Partner-center-rest-api create referral
Hi!
I´m trying to create a new referral (Co-Sell Opportunity) following the REST API documentation here but I always get a "Unauthorized" or "Bad request" response.
I properly get and update referrals using the same API. My sample code is:
var request = new HttpRequestMessage(HttpMethod.Post, $"https://api.partner.microsoft.com/v1.0/engagements/referrals");
await this.auth.AuthenticateRequestAsync(request);
request.Headers.Add("client-request-id", Guid.NewGuid().ToString()); //From: https://learn.microsoft.com/en-us/partner/develop/headers
request.Headers.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
string serializedObject = JsonConvert.SerializeObject(newReferral);
request.Content = new StringContent(serializedObject, Encoding.UTF8, "application/json");
log.LogInformation("[API.CreateReferral] Req Headers: " + request.Headers);
var response = await httpClient.SendAsync(request); //POST: Bad Request GET: Ok, Empty return Referral
response = await httpClient.PostAsync(request.RequestUri, request.Content); // POST: Unauthorized GET: Unauthorized
response.EnsureSuccessStatusCode();
using (var stream = await response.Content.ReadAsStreamAsync())
{
createdReferral = await System.Text.Json.JsonSerializer.DeserializeAsync<Referral>(stream, serializeOptions);
}
As you can see above, I tried, just for testing purposes, by SendAsync and PostAsync with different responses. I also tried to change new HttpRequestMessage(HttpMethod.Post by HttpMethod.Get just as desperation tests and I get an Ok with a empy Refererral bodu on response.
I also tried the Partener Center Store nuget SDK, but it doesn´t contains method for managing Referrals.
Any idea about what my issue could be?
Thanks in advance.
Best regards.