calling google Url Shortner API in C#

后端 未结 4 767
孤独总比滥情好
孤独总比滥情好 2021-02-08 10:36

I want to call the google url shortner API from my C# Console Application, the request I try to implement is:

POST https://www.googleapis.com/urlshortener

4条回答
  •  半阙折子戏
    2021-02-08 10:58

    How about changing

       var requestContent = new FormUrlEncodedContent(new[] 
            {new KeyValuePair("longUrl", s),});
    

    to

       var requestContent = new StringContent("{\"longUrl\": \" + s + \"}");
    

提交回复
热议问题