python api of google adwords(googleads) is giving "INVALID_CONVERSION_TYPE" when calling the OfflineConversionAdjustmentFeed operation - google-ads-api

I am using googleads API to perform the following operations:
- (1) upload new conversions
- (2) adjust uploaded conversions
The first operation could be done successfuly.
However the second opeartion which is the adjustment of the uploaded conversion is giving the error "INVALID_CONVERSION_TYPE".
According to the documentation in https://developers.google.com/adwords/api/docs/reference/v201809/OfflineConversionFeedService.OfflineConversionError#reason.
The reason for this error is that the conversion name does not match any uploaded conversion for the same customer,
although i have uploaded the conversion with the same conversion name for the same customer.
I am posting my request and the response i am receiving:
request=[{
'operator': 'ADD',
'operand':
{
'adjustmentTime': '20190802 235959 Etc/GMT',
'googleClickId': 'gcliID',
'adjustedValueCurrencyCode': 'EUR',
'conversionName': 'YY',
'adjustedValue': xx,
'xsi_type': 'GclidOfflineConversionAdjustmentFeed',
'conversionTime': '20190731 235959 Etc/GMT',
'adjustmentType': 'RESTATE'
}
}
]
response = {
'ListReturnValue.Type': 'OfflineConversionAdjustmentFeedReturnValue',
'value': [
{
'conversionName': None,
'adjustmentTime': None,
'adjustmentType': None,
'adjustedValue': None,
'adjustedValueCurrencyCode': None,
'OfflineConversionAdjustmentFeed.Type': 'GclidOfflineConversionAdjustmentFeed',
'googleClickId': None,
'conversionTime': None
}
],
'partialFailureErrors': [
{
'fieldPath': 'operations[0].operand.conversionName',
'fieldPathElements': [
{
'field': 'operations',
'index': 0L
},
{
'field': 'operand',
'index': None
},
{
'field': 'conversionName',
'index': None
}
],
'trigger': None,
'errorString': 'OfflineConversionAdjustmentError.INVALID_CONVERSION_TYPE',
'ApiError.Type': 'OfflineConversionAdjustmentError',
'reason': 'INVALID_CONVERSION_TYPE'
}
]
}

Have you ever solved this issue? I'm having the very same one. The only solution I could find is not to use gclid, but switched to orderId - now adjustment works for me.

Related

How Do I Pass Previous resultPaths to Result.fromObject Pass Task in AWS Step Functions

I am trying to create an object, from which some are static values, and others are the outcomes of previous tasks. How do I access them?
Current CDK Code:
this.setupIteration = new Pass(this, "Setup Iteration", {
result: Result.fromObject({
"count": "$.skusLength",
"index": 0,
"step": 1
}),
resultPath: "$.iterator",
});
Error: I am just getting the string "$.skusLength" instead of the actual value that is available above. I have also tried JsonPath.numberAt and JsonPath.stringAt, with no success.
CDK Docs: https://docs.aws.amazon.com/cdk/api/v1/docs/#aws-cdk_aws-stepfunctions.Result.html
Change result to parameters:
this.setupIteration = new Pass(this, "Setup Iteration", {
parameters: {
"count": JsonPath.numberAt("$.skusLength"),
"index": 0,
"step": 1
},
resultPath: "$.iterator",
});

How To Convert "created_timestamp" Value To A Valid Date In Python

I'm currently working on a Twitter bot that automatically reply messages, I'm doing this by using tweepy (the official python twitter library)
I need to filter messages based on the created time as I don't want to reply same message twice. Now the problem is that the API endpoint returns created_timestamp as string representation of positive integers.
Below is an example of data returned as per the doc
{
"next_cursor": "AB345dkfC",
"events": [
{ "id": "110", "created_timestamp": "1639919665615", ... },
{ "id": "109", "created_timestamp": "1639865141987", ... },
{ "id": "108", "created_timestamp": "1639827437833", ... },
{ "id": "107", "created_timestamp": "1639825389806", ... },
{ "id": "106", "created_timestamp": "1639825389796", ... },
{ "id": "105", "created_timestamp": "1639825389768", ... },
...
]
}
My question is "How do I convert the created_timestamp to a valid date using python" ?.
You might play with timestamps on this resource
And in your case could use methods like:
timestamp = int('timestamp_string')
datetime.fromtimestamp(timestamp, tz=None)
date.fromtimestamp(timestamp)
From the datetime standard library. But integers after the first line are already well comparable if the task is to distinguish differences between the timestamps.

updateShapeProperties complaining about missing fields property

Details
OS: Manjaro Linux
Node.js version: 10
npm version: 6
googleapis version: 51.0.0
Steps to reproduce
We are sending a google slide API request with updateShapeProperties:
"updateShapeProperties": {
"objectId": objectId,
"shapeProperties": {
"shapeBackgroundFill": {
"solidFill": {
"color": {
"rgbColor": {
"red": r,
"green": g,
"blue": b
}
},
"alpha": 1
}
},
"outline": {
"outlineFill": {
"solidFill": {
"color": {
"rgbColor": {
"red": 0,
"green": 0,
"blue": 0
}
},
"alpha": 0.1
}
},
},
"contentAlignment": "MIDDLE"
},
"fields": "*"
}
where objectId comes from one of any pageElement we get from slide.pageElements
We get a 400 response that states:
message: ""Invalid requests[2].updateShapeProperties: At least one field must be listed in 'fields'. (Use '*' to indicate all fields.)
This somehow used to work the past few months, and was wondering why it suddenly doesn't work right now. Did we have any changes or updates on the updateShapeProperties API?
I believe that [2] of Invalid requests[2].updateShapeProperties is the request body in your question. When I tested your request body, I could replicate your situation. The error message is At least one field must be listed in 'fields'. (Use '*' to indicate all fields.). When I tested "fields": "", I got the same error message. From this situation, I thought that it might be a bug.
When I searched this situation at the Google issue tracker, I found it. Ref
So as the current workaround, in order to avoid this error, in your request body, how about the following modification?
From:
"fields": "*"
To:
"fields": "shapeBackgroundFill,outline,contentAlignment"

With Google Cloud Speech-to-text, why do I get different results for the same audio file, depending on which bucket do I put it into?

I am trying to use Google Cloud Speech-to-text, using the client libraries, from a node.js environment, and I see something I don't understand: I get a different result for the same example audio file, and the same configuration, depending on whether I am using it from the original sample bucket, or from my own bucket.
There are the requests and responses:
The baseline is Google's own test data file, available here: https://storage.googleapis.com/cloud-samples-tests/speech/brooklyn.flac
Request:
{
"config": {
"encoding": "FLAC",
"languageCode": "en-US",
"sampleRateHertz": 16000,
"enableAutomaticPunctuation": true
},
"audio": {
"uri": "gs://cloud-samples-tests/speech/brooklyn.flac"
}
}
Response:
{
"results": [
{
"alternatives": [
{
"transcript": "How old is the Brooklyn Bridge?",
"confidence": 0.9831430315971375
}
]
}
]
}
So far, so good. But, if I download this audio file, re-upload it to my own bucket, and do the same, then:
Request:
{
"config": {
"encoding": "FLAC",
"languageCode": "en-US",
"sampleRateHertz": 16000,
"enableAutomaticPunctuation": true
},
"audio": {
"uri": "gs://goe-transcript-creation/brooklyn.flac"
}
}
Response:
{
"results": [
{
"alternatives": [
{
"transcript": "how old is",
"confidence": 0.8902621865272522
}
]
}
]
}
As you can see this is the same request. The re-uploaded audio data is here: https://storage.googleapis.com/goe-transcript-creation/brooklyn.flac
This the exact same file as in the first example... not a bit of difference.
Still, the results are different; I only get half of the sentence.
What am I missing here? Thanks.
Update 1:
The same thing happens with the CLI tool, too:
$ gcloud ml speech recognize gs://cloud-samples-tests/speech/brooklyn.flac --language-code=en-US
{
"results": [
{
"alternatives": [
{
"confidence": 0.98314303,
"transcript": "how old is the Brooklyn Bridge"
}
]
}
]
}
$ gcloud ml speech recognize gs://goe-transcript-creation/brooklyn.flac --language-code=en-US
ERROR: (gcloud.ml.speech.recognize) INVALID_ARGUMENT: Invalid recognition 'config': bad encoding..
$ gcloud ml speech recognize gs://goe-transcript-creation/brooklyn.flac --language-code=en-US --encoding=FLAC
ERROR: (gcloud.ml.speech.recognize) INVALID_ARGUMENT: Invalid recognition 'config': bad sample rate hertz.
$ gcloud ml speech recognize gs://goe-transcript-creation/brooklyn.flac --language-code=en-US --encoding=FLAC --sample-rate=16000
{
"results": [
{
"alternatives": [
{
"confidence": 0.8902483,
"transcript": "how old is"
}
]
}
]
}
It's also interesting that when pulling the audio from the other bucket, I need to specify encoding and sample rate, otherwise it doesn't work... but it's not necessary when I am using the original test bucket.
Update 2:
If I don't use Google Cloud Storage, but upload the data directly in the speech-to-text request, it works as intended:
$ gcloud ml speech recognize brooklyn.flac --language-code=en-US
{
"results": [
{
"alternatives": [
{
"confidence": 0.98314303,
"transcript": "how old is the Brooklyn Bridge"
}
]
}
]
}
So the problem doesn't seems to be with the recognition itself, but accessing the audio data. The obvious guess would be that maybe it's the fault of the uploading, and the data is somehow corrupted along the way?
We can verify that by pulling the data from the cloud, and comparing with the original. It doesn't seem to be broken.
So maybe it's a problem when the S-T-T service is accessing the storage service? But why with one bucket only? Or is it some kind of file metadata problem?

Twitter: Error sending Direct message with quick reply buttons

I need to send a Twitter DM with quick reply.
I use Tweetinvi, that at the moment does not support quick replies, therefore I tried to alter the query in Tweetinvi code at the lovest possible level: just before it is sent to Twitter.
If I send this (basic message)
https://api.twitter.com/1.1/direct_messages/new.json?text=hello&user_id=999999999
It works
When I send is this
https://api.twitter.com/1.1/direct_messages/new.json?text=MessageToUserId&user_id=999999999&quick_reply&type=options&options=[label=RedBird&description=Adescriptionabouttheredbird.&metadata=external_id_1]
I get status 401 Web request failed.
To build my request I tried to simplify this example:
https://developer.twitter.com/en/docs/direct-messages/quick-replies/api-reference/options
But I am missing something. I suppose it is a trivial mistake in the query. I tried several variations, but I cannot get a better result. Of course in my code I use a real userId, that here I masked with 9.
Can you suggest me a working correction to my query? (maybe with examples using multiple labels)
Update.
I tried to use TwitterAccessor (without hacks in Tweetinvi code) and improved the json
Here is my updated code
Auth.SetUserCredentials(consumerKey, consumerSecret, userAccessToken, userAccessSecret);
var authenticatedUser = User.GetAuthenticatedUser();
var qString = JsonConvert.DeserializeObject("{ 'event': { 'type': 'message_create', 'message_create': { 'target': { 'recipient_id': '123456789' }, 'sender_id': '987654321', 'message_data': { 'text': 'option?', 'quick_reply': { 'type': 'options', 'options': [ { 'label': 'option 1', 'metadata': 'val1', 'description': 'option 2' }, { 'label': 'val2', 'metadata': 'option 3', 'description': 'val3' } ] } } } } }");
var strEncoded = WebUtility.HtmlEncode(qString.ToString());
var url = "https://api.twitter.com/1.1/direct_messages/events/new.json";
var result = TwitterAccessor.TryExecutePOSTQuery($"{url}?{strEncoded}");
Now I have error 401, with this description:
"Unauthorized - Authentication credentials were missing or incorrect."
Which is much better. Probably I just need to add credential headers using TwitterAccessor, but I need help about this.
I suppose that adding something TwitterAccessor. Method to create credentials headers before the post should do the job.

Resources