Does the MutateMediaFiles service work for images yet?

35 views
Skip to first unread message

jo...@greenfieldlabs.ca

unread,
Feb 4, 2019, 9:16:05 AM2/4/19
to AdWords API and Google Ads API Forum
I have been trying to do run a create MediaFileOperation on an image but keep getting "INVALID_ARGUMENT" as a response. So, I'm curious if this is actually implemented yet on the Beta API. I did not find media_file.image here: https://developers.google.com/google-ads/api/docs/fields/media_file

If this is not available, is there a way to upload the image through the UI and also receive the resource_name of the image? Or is there another way that I haven't considered yet?

googleadsapi...@google.com

unread,
Feb 4, 2019, 4:20:06 PM2/4/19
to AdWords API and Google Ads API Forum
Hello John,

The resource media_file does not have the field media_file.image that the reson for INVALID_ARGUMENT error, instead you could use the media_file.resource_name field. You can use the UI of Google Ads API to upload the media files. To upload media files via Google Ads API you could use MutateMediaFiles operation as shown here.

Regards,
Sai Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

jo...@greenfieldlabs.ca

unread,
Feb 4, 2019, 4:50:55 PM2/4/19
to AdWords API and Google Ads API Forum
Hi Sai,

I wasn't using meda_file.image for an argument. I was pointing that to asking if the functionality was available. I am writing the code in Scala.

val mediaFile: MediaFile = MediaFile.newBuilder
 
.setName("myimage")
 
.setType(MediaType.IMAGE)
 
.build

val mediaFileOps
: java.util.List[MediaFileOperation] = java.util.Arrays.asList(
 
MediaFileOperation.newBuilder.setCreate(mediaFile).build
)

val mediaFileServiceClient
: MediaFileServiceClient = dependencies.gadsClient.getMediaFileServiceClient

val response
: MutateMediaFilesResponse = mediaFileServiceClient.mutateMediaFiles('adAccountIdHere', mediaFileOps)

This response returns INVALID_ARGUMENT. Can you explain where the invalid argument is?

I know I can use the Google UI to upload images, however I do not know how to retrieve the resource_name from this. Can you explain how I can get the resource_name from the UI?

Thanks,
John

googleadsapi...@google.com

unread,
Feb 5, 2019, 3:02:28 PM2/5/19
to AdWords API and Google Ads API Forum
Hello John,

Looks like the INVALIDARGUMENT is due to the .setName() method which is expecting StringValue.of("myimage") as an argument instead. You could refer to the below snippet to build MediaFile object in Java (Since we do not have client libraries in Scala, providing the snippet in the Java). 

Snippet:
MediaFile mediaFile = MediaFile.newBuilder()
                     .setName(StringValue.of("myimage"))
                     .setType(MediaType.IMAGE)
                     .build();

Please let me know if you have any further questions.


Regards,
Sai Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

jo...@greenfieldlabs.ca

unread,
Feb 5, 2019, 3:24:48 PM2/5/19
to AdWords API and Google Ads API Forum
Hi Sai,

I tried doing what you said below but unfortunately it's still giving an INVALID_ARGUMENT error.

Can you check if there is something incomplete or the error is on Google's end? If you're sure that the issue is not on my end, can you provide a full Java snippet that you have tested that I could run myself?

FYI - I have been able to create Campaigns & Ad Groups without any issues.

Thank you again for your help,
John

jo...@greenfieldlabs.ca

unread,
Feb 5, 2019, 3:39:58 PM2/5/19
to AdWords API and Google Ads API Forum
Ah crap! It looks like I was making the mistake of not sending the actual file. I think this might be the issue.

googleadsapi...@google.com

unread,
Feb 6, 2019, 1:03:54 PM2/6/19
to AdWords API and Google Ads API Forum
Hello John,

We are looking into the issue and we will get back to you shortly.

Regards,
Sai Teja, AdWords API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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 and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/3f7a6e50-4e2d-4f79-8ec2-f0cea1846b60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jo...@greenfieldlabs.ca

unread,
Feb 6, 2019, 1:10:38 PM2/6/19
to AdWords API and Google Ads API Forum
Thanks Sai - however there doesn't seem to be an issue on your end. I had the wrong error from another call. I have been able to successfully upload an image and the the resource name. Thanks for all your help. I'm sorry for my mistake.

googleadsapi...@google.com

unread,
Feb 6, 2019, 2:23:15 PM2/6/19
to AdWords API and Google Ads API Forum
Hello John,

Glad you were able to solve the issue.


Regards,
Sai Teja, Google Ads API Team


=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Reply all
Reply to author
Forward
0 new messages