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

URL tags creating error (V2.6) #38

Closed
sang-d opened this issue Jul 18, 2016 · 5 comments
Closed

URL tags creating error (V2.6) #38

sang-d opened this issue Jul 18, 2016 · 5 comments

Comments

@sang-d
Copy link

sang-d commented Jul 18, 2016

Hi,
I'm still using v2.6 and I got this error while creating ad with url_tags having more than 1 value:

creative to submit:
{"body":"test desc","image_hash":"c6e035cb89c48000b7e5eb8af0e2b012","link_url":"http://sdinh.net","object_url":"http://sdinh.net","title":"my headline","url_tags":"key=1&key=2"}

error:
{\"message\":\"(#100) Creative spec must be an associative array (optionally json-encoded)

It happened with different type of creative (Domain, Post page ad...).
Can you take a look and advise.

Thanks,
Sang

@JiamingFB
Copy link
Contributor

Hi sang-d,

It might be related to json escaping of special characters. Would you mind posting some code snippet of your code?

Also, you can pass an AdCreative object as param instead of a json string, which would better handle the encoding.

Thanks!

@sang-d
Copy link
Author

sang-d commented Jul 19, 2016

hi JiamingFB,
Thanks for quick response. Following is code section to create the ad:

AdCreative creative = new AdCreative(); creative.setFieldTitle(obj.getString("title")); creative.setFieldBody(obj.getString("body")); creative.setFieldLinkUrl(obj.getString("link_url")); creative.setFieldObjectUrl(obj.getString("object_url")); creative.setFieldImageHash(obj.getString("image_hash")); if (obj.has("url_tags")) { creative.setFieldUrlTags(obj.getString("url_tags")); }

BatchRequest batch = new BatchRequest(context); APIRequestCreateAd req = account.createAd().setAdsetId(adsetId).setCreative(creative).setName(variantName) .setStatus(Ad.EnumStatus.VALUE_PAUSED); req.addToBatch(batch);

Thanks,
Sang

@sang-d
Copy link
Author

sang-d commented Jul 21, 2016

hi JiamingFB,

This issue happens only when creating ad in a BATCH request.
I just tried with single request execute, then it works fine.

For eg above, if I set:
creative.setFieldUrlTags("k=1&x=2&y=3");
It will throw error. Or it also happens if i put:
creative.setFieldLinkUrl("http://sdinh.net?k=1&x=2&y=3");

Please take a look.
Thanks
Sang

@JiamingFB
Copy link
Contributor

Hi sang-d,

Looks like there is a bug in encoding when assembling batch request. The "body" in batch request is supposed to be url-encoded, but it's not encoded right now.

Sorry for the inconvenience. I'll work on the fix.

@JiamingFB
Copy link
Contributor

I just applied a patch for it in latest code. Looks like the encoding bug has been there for a while, but seemingly it didn't break the request (server has some level of tolerance) unless the body contains special characters like "&"

If you want to stay in v2.6, you can copy that one-line change :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants