Posts tagged with c#

I am trying to send a pdf through WhatsApp Business API that is stored in google drive, but I am receiving an error " 12300 - Invalid Content-Type " can you help me where am I going wrong also, I want to know how to send a pdf in MediaUrl from my local storage. I tried using Twilio Assets but it's also not working. Here is my code:

 static void Main(string[] args) {     var accountSid = " ";     var authToken = " ";     TwilioClient.Init(accountSid, authToken);     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;     var mediaUrl = new[] {         new Uri("google drive link")     }.ToList();          var messageOptions = new CreateMessageOptions(         new PhoneNumber("whatsapp:+91XXXXXX"));     messageOptions.From = new PhoneNumber("whatsapp:+XXXXXXXX");     messageOptions.Body = "Hello how are you?";     messageOptions.MediaUrl = mediaUrl;     var message = MessageResource.Create(messageOptions);     Console.WriteLine(message.Body);     Console.ReadLine(); } 

Hi I have been using rest methods to integrate Google Ads API in C#. Everything seemed to be working fine but all of sudden I started getting 400 response with the error message.

{     "error": "invalid_grant",     "error_description": "Token has been expired or revoked." } 

As mentioned above that I am not using client library but instead using restsharp and testing all my end points using postman also.

Any reason why it is happening? My refresh token is also valid. I have been using this for one week. I have also not reached to the limit of refresh token as I have only generated refresh token 3 to 4 times when I was trying to set up the accounts.

I believe the validity of refresh token is life long then why it is happening?

I am currently trying to integrate single Google Ads account for my client using RestSharp in C# (don't want to use client libraries). I have found the useful link to generate access token by providing client ID , Client secret and Refresh token.

https://developers.google.com/google-ads/api/docs/rest/auth

I am now trying to test on Postman first before I start developing code in C# but failing to get access token. The screen shot below shows the call I am doing to get access token using Post man.

I also tried CURL in postman which was mentioned in the link above but getting the same error.

FYI it is a Desktop app chosen in google console to generate client ID and secrete because I will be creating console app to integrate Google Ads API.

The Company I work with has many clients who uses Google Ads to do marketing for their websites. The company wants to use client's data for Analysis. I am given a project to integrate Google Ads API using C# to get all the data such as Campaigns etc from Google ads and move it to our system for each client. I am only given developer token and customerID for Clients. such as

  1. Customer ID for Client A
  2. Customer ID for Client B

I am bit lost when I went through the google ads API documentation. In the documentation, the OAuth2.0 needs creating in order to use client library which would generate client ID and Client Secret, Refresh token to integrate the API. My question is. Do I need to create OAuth2.0 for each client or do I need to ask my company to generate Client ID and secret in company's Manager Account or Client that uses Google ads would provide me these?

The following Link I found to create OAuth2.

https://developers.google.com/google-ads/api/docs/oauth/cloud-project

This is what I believe would require in C# Content can be found at https://developers.google.com/adwords/api/docs/guides/first-api-call#.net_1

Would highly appreciate if any one can help me what actually I need to configure google ads using C#