Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MutateLabelsRequest.Operations cannot be assigned to -- It is read-only #346

Closed
powell-graphika opened this issue Feb 7, 2022 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@powell-graphika
Copy link

Describe the bug:
MutateLabelsRequest.Operations is currently set to "read-only". Users should be able to create new label with this function.

labelService: https://developers.google.com/google-ads/api/reference/rpc/v9/LabelService?hl=en
MutateLabelsRequest: https://developers.google.com/google-ads/api/reference/rpc/v9/MutateLabelsRequest

Steps to Reproduce:

        //1. Create label --> get labellID
        var test_label = new TextLabel();
        test_label.BackgroundColor = "#FFFFFF";           // In RGB: current setting white background
        test_label.Description = "test_label_Location1";  // string for labeling...currently using location Number


        List<LabelOperation> operations = new List<LabelOperation>();

        // Creates the campaign label.
        TextLabel label = new TextLabel()
        {
            BackgroundColor = "#FFFFFF",           // In RGB: current setting white background
            Description = "test_label_Location1"   // string for labeling...
        };

        Google.Ads.GoogleAds.V8.Resources.Label label2 = new Label()
        {
            TextLabel = label
        };

        operations.Add(new LabelOperation()
        {
            Create = label2
        });

         Google.Ads.GoogleAds.V8.Services.MutateLabelsRequest request = new MutateLabelsRequest()
        {
            CustomerId = customerId.ToString(),
            Operations = //read-only?
            // bug report: 
        };

Expected behavior:

MutateLabelsRequest.Operations should not just be read-only (get). It should allow user to input as well (both get and set).

Client library version and API version:
Client library version: Google.Api.Gax.Grpc 3.6.0
Google Ads API version: V8
.NET version: netcoreapp3.1
Operating system: Windows 10

Please refer to the attachment for the code

google_mutatelabelrequest_issue

@powell-graphika powell-graphika added the bug Something isn't working label Feb 7, 2022
@AnashOommen
Copy link
Member

You can use one of the following approaches. (I am using MutateCampaignsRequest, others are similar).

List<CampaignOperation> campaignOperations = new List<CampaignOperation>();

// Newer C# versions with collection initialization syntax.
MutateCampaignsRequest request = new MutateCampaignsRequest()
{
    CustomerId = customerId.ToString(),
    Operations = { campaignOperations }
 };
 // Older C# versions.
 request.Operations.AddRange(campaignOperations);

@AnashOommen AnashOommen self-assigned this Feb 15, 2022
@AnashOommen AnashOommen pinned this issue Feb 15, 2022
@powell-graphika
Copy link
Author

@AnashOommen I tried the method you provided, specifically:

  • adding the brackets to the input to Operations to bypass the error I previously encountered

I got the following error:

'''
Failure:
Message: Status(StatusCode="InvalidArgument", Detail="Request contains an invalid argument.", DebugException="Grpc.Core.Internal.CoreErrorDetailException: {"created":"@1645086228.165000000","description":"Error received from peer ipv4:142.251.41.74:443","file":"......\src\core\lib\surface\call.cc","file_line":1068,"grpc_message":"Request contains an invalid argument.","grpc_status":3}")
Failure: { "errors": [ { "errorCode": { "stringLengthError": "EMPTY" }, "message": "The specified field should have a least one non-whitespace character in it.", "trigger": { "stringValue": "" }, "location": { "fieldPathElements": [ { "fieldName": "operations", "index": 0 }, { "fieldName": "create" }, { "fieldName": "name" } ] } } ], "requestId": "hfb1FvhZQr2R5cZ1J1E14g" }
Request ID: hfb1FvhZQr2R5cZ1J1E14g
'''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants