Hi Conor,

See if you can replicate this one - connection getting closed is sometimes 
related to a bad ISP connection, sometimes it happens due to your calls 
happening when a server update is happening.

Cheers,
Anash P. Oommen,
AdWords API Advisor.

On Monday, September 29, 2014 5:53:10 AM UTC-4, testa...@geeks.ltd.uk wrote:
>
> Hi Anash,
>
> Thank you for your reply. I made a couple of changes to my code, so it now 
> looks like this:
>
>         var operations = new List<AdGroupAdOperation>();
>
>         foreach (var generatedAd in generatedAds)
>         {
>             // create a new image to put in the imageAd
>             var image = new Image
>             {
>                 data = generatedAd.Image.FileData,
>                 type = MediaMediaType.IMAGE
>             };
>
>             // create a new image ad
>             var imageAd = new ImageAd
>             {
>                 image = image,
>                 name = generatedAd.Image.FileName,
>                 displayUrl = Config.Get("DisplayURL"),
>                 url = generatedAd.Ad.Url
>             };
>
>             var imageAdGroupAd = new AdGroupAd
>             {
>                 ad = imageAd,
>                 adGroupId = (long)generatedAd.Ad.AdwordsAdGroupId,
>                 
>             };
>
>             // prepare to add the new image ad to the ad words group
>             var operation = new AdGroupAdOperation
>             {
>                 @operator = Operator.ADD,
>                 operand = imageAdGroupAd
>             };
>
>             operations.Add(operation);
>         }
>
>         try
>         {
>             
> ((AdGroupAdService)user.GetService(AdWordsService.v201406.AdGroupAdService))
>                 .mutate(operations.ToArray());
>         }
>
> However, running this code now results in an exception being thrown. The 
> main exception message is 'The underlying connection was closed: An 
> unexpected error occurred on a send.', and the inner exception message is 
> 'An existing connection was forcibly closed by the remote host.'. Have 
> these errors come up before in AdWords? Is there a particular way to handle 
> them?
>
> Thanks,
> Conor
>
>
> On Friday, 26 September 2014 21:01:48 UTC+1, Anash P. Oommen (AdWords API 
> Team) wrote:
>>
>> Hi Conor,
>>
>> This is a code example from an old version of the client library. Let me 
>> know if it works for you.
>>
>>       // Create your image ad.      ImageAd imageAd = new ImageAd();      
>> imageAd.name = "My Image Ad";      imageAd.displayUrl = "www.example.com";   
>>    imageAd.url = "http://www.example.com 
>> <https://www.google.com/url?q=http://www.example.com&usg=AFQjCNGH9WGZ0rgKFLCMkObqewQjm4Gotw>";
>>       // Load your image into data field.      string imageUrl = 
>> "https://sandbox.google.com/sandboximages/image.jpg 
>> <https://www.google.com/url?q=https://sandbox.google.com/sandboximages/image.jpg&usg=AFQjCNFzC3A1uAlzhaOkqVoOs3fzZ0lmaw>";
>>       WebRequest request = HttpWebRequest.Create(imageUrl);      WebResponse 
>> response = request.GetResponse();      MemoryStream memStream = new 
>> MemoryStream();      using (Stream responseStream = 
>> response.GetResponseStream()) {        byte[] strmBuffer = new byte[4096];   
>>      int bytesRead = responseStream.Read(strmBuffer, 0, 4096);        while 
>> (bytesRead != 0) {          memStream.Write(strmBuffer, 0, bytesRead);       
>>    bytesRead = responseStream.Read(strmBuffer, 0, 4096);        }      }     
>>  imageAd.image = new Image();      imageAd.image.data = memStream.ToArray(); 
>>      // Set the AdGroup Id.      AdGroupAd imageAdGroupAd = new AdGroupAd(); 
>>      imageAdGroupAd.adGroupId = adGroupId;      
>> imageAdGroupAd.adGroupIdSpecified = true;      imageAdGroupAd.ad = imageAd;
>>
>>
>> Cheers,
>> Anash P. Oommen,
>> AdWords API Advisor.
>>
>> On Thursday, September 25, 2014 10:26:52 AM UTC-4, testa...@geeks.ltd.uk 
>> wrote:
>>>
>>> HI Anash,
>>>
>>> Thanks for your help. I am slightly lost though as to how to create an 
>>> ImageAd, from start to finish. So I upload the Image to AdWords, and get 
>>> the media id of that image. Then what do I do with it? I'm looking at the 
>>> API here 
>>> https://developers.google.com/adwords/api/docs/reference/v201406/AdGroupAdService.ImageAd
>>>  
>>> and can't see where I should put the id. I also don't know what the 
>>> following steps are. 
>>>
>>> I have downloaded the AdWords examples for C# but there are no 
>>> references to ImageAd, so I can't see how it's done.
>>>
>>> Thanks,
>>> Conor
>>>
>>> On Thursday, 25 September 2014 14:19:46 UTC+1, Anash P. Oommen (AdWords 
>>> API Team) wrote:
>>>>
>>>> Hi,
>>>>
>>>> To create an imageAd, you'd need to upload the image first using 
>>>> MediaService (see 
>>>> https://github.com/googleads/googleads-dotnet-lib/blob/master/examples/AdWords/CSharp/v201406/Miscellaneous/UploadImage.cs),
>>>>  
>>>> then use that media id to create an image Ad.
>>>>
>>>> Cheers,
>>>> Anash P. Oommen,
>>>> AdWords API Advisor.
>>>>
>>>> On Thursday, September 25, 2014 7:21:24 AM UTC-4, testa...@geeks.ltd.uk 
>>>> wrote:
>>>>>
>>>>> Hi All,
>>>>>
>>>>> I am trying to use the following code, in C#, to upload some ImageAds 
>>>>> to AdWords; however, it appears that I am using the wrong service. 
>>>>> However, 
>>>>> using a MediaService forces me to change method from mutate to upload, 
>>>>> the 
>>>>> argument from List<AdGroupAdOperation> to Media[], and then I have to 
>>>>> change the type from ImageAd to Image, otherwise I can't put it in the 
>>>>> array, and then I can't assign certain information, such as AdGroupId, 
>>>>> which I need to specify.
>>>>>
>>>>> Does anyone know where I'm going wrong or what I should be doing 
>>>>> instead to achieve my goal of putting certain ImageAds in a certain 
>>>>> AdGroup?
>>>>>
>>>>> Thanks,
>>>>> Conor
>>>>>
>>>>> ========================== Code ========================== 
>>>>>         var operations = new List<AdGroupAdOperation>();
>>>>>
>>>>>         foreach (var generatedAd in generatedAds)
>>>>>         {
>>>>>             // create a new image to put in the imageAd
>>>>>             var image = new Image
>>>>>             {
>>>>>                 data = generatedAd.Image.FileData,
>>>>>                 type = MediaMediaType.IMAGE
>>>>>             };
>>>>>
>>>>>             // create a new image ad
>>>>>             var imageAd = new ImageAd
>>>>>             {
>>>>>                 image = image,
>>>>>                 displayUrl = DisplayURL,
>>>>>                 url = generatedAd.Ad.Url
>>>>>             };
>>>>>
>>>>>             var imageAdGroupAd = new AdGroupAd
>>>>>             {
>>>>>                 adGroupId = (long)generatedAd.Ad.AdwordsAdGroupId
>>>>>             };
>>>>>
>>>>>             // prepare to add the new image ad to the ad words group
>>>>>             var operation = new AdGroupAdOperation
>>>>>             {
>>>>>                 @operator = Operator.ADD,
>>>>>                 operand = imageAdGroupAd
>>>>>             };
>>>>>
>>>>>             operations.Add(operation);
>>>>>         }
>>>>>
>>>>>         try
>>>>>         {
>>>>>             
>>>>> ((AdGroupAdService)user.GetService(AdWordsService.v201406.AdGroupAdService))
>>>>>                 .mutate(operations.ToArray());
>>>>>         }
>>>>> ========================== Code ========================== 
>>>>>
>>>>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/adwords-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/d2a4b3ea-18e4-4ab7-b9ce-762bf92537d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to