API контактов SendGrid - PullRequest
       4

API контактов SendGrid

0 голосов
/ 10 июля 2019

Я пытаюсь добавить получателя в свой список контактов. Вот код:

this._client = new SendGridClient(this._options.Value.SendGridKey);

var recipientId = Guid.NewGuid().ToString();
            var uri = new Uri($"{BASE_URL}/contactdb/recipients");
            var httpMessage = new HttpRequestMessage(HttpMethod.Post, uri);
            var emailModel = new EmailModel()
            {
                email = email,
                name = "Anna",
                age = 26.ToString(),
                pet = "caaaaat"
            };
            var emailJson = JsonConvert.SerializeObject(emailModel); 
            httpMessage.Content = new ObjectContent(typeof(EmailModel), emailModel, new JsonMediaTypeFormatter());
            var response = await this._client.MakeRequest(httpMessage);```

The code returns bad request, and I just don't know why. Anyone else had this problem?
...