Sandbox API - campaign creation


#1

I’m developing against the ads api sandbox (https://ads-api-sandbox.twitter.com) and I am unable to create a campaign. I can successfully make other requests but I am not able to make a campaign.

I am using twurl to do the test.


Creating an ad campaign in the sandbox
#2

Are you able to share any additional information, such as error codes returned?


#3

It returns

{"errors":[{"code":"UNAUTHORIZED_ACCESS","message":"This request is not properly authenticated"}],"request":{"params":{}}}

The oauth fields (oauth_consumer_key, oauth_nonce, oauth_signature, oauth_signature_method, oauth_timestamp, oauth_token, and oauth_version are all present)

I am able to successfully make other requests to the sandbox.


#4

Can you provide the full twurl command you’re executing and perhaps the @username under which you authenticated twurl? I find curious that the “params” attribute is empty in the error you receive.


#5
twurl -H https://ads-api-sandbox.twitter.com /0/accounts/gq0vll/campaigns -d '{"name": "funky town ad", "funding_instrument_id": "hxciz", "start_time": "2015-07-05T07:00:00Z", "end_time": "2015-07-25T07:00:00Z", "daily_budget_amount_local_micro": 50000000, "total_budget_amount_local_micro": 500000000, "account_id": "gq0vll" "paused": true}' -t
opening connection to ads-api-sandbox.twitter.com:443...
opened
starting SSL for ads-api-sandbox.twitter.com:443...
SSL established
<- "POST /0/accounts/gq0vll/campaigns HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: OAuth gem v0.4.7\r\nContent-Type: application/x-www-form-urlencoded\r\nAuthorization: OAuth oauth_consumer_key=\"<REDACTED>\", oauth_nonce=\"<REDACTED>\", oauth_signature=\"<REDACTED>%3D\", oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1430346406\", oauth_token=\"<REDACTED>\", oauth_version=\"1.0\"\r\nConnection: close\r\nHost: ads-api-sandbox.twitter.com\r\nContent-Length: 355\r\n\r\n"
<- "%7B%22name%22%3A+%22funky+town+ad%22%2C+%22funding_instrument_id%22%3A+%22hxciz%22%2C+%22start_time%22%3A+%222015-07-05T07%3A00%3A00Z%22%2C+%22end_time%22%3A+%222015-07-25T07%3A00%3A00Z%22%2C+%22daily_budget_amount_local_micro%22%3A+50000000%2C+%22total_budget_amount_local_micro%22%3A+500000000%2C+%22account_id%22%3A+%22gq0vll%22+%22paused%22%3A+true%7D"
-> "HTTP/1.1 401 Authorization Required\r\n"
-> "connection: close\r\n"
-> "content-disposition: attachment; filename=json.json\r\n"
-> "content-encoding: gzip\r\n"
-> "content-length: 139\r\n"
-> "content-type: application/json;charset=utf-8\r\n"
-> "date: Wed, 29 Apr 2015 22:27:53 GMT\r\n"
-> "server: tsa_b\r\n"
-> "set-cookie: guest_id=v1%3A143034647340708414; Domain=.twitter.com; Path=/; Expires=Fri, 28-Apr-2017 22:27:53 UTC\r\n"
-> "strict-transport-security: max-age=631138519\r\n"
-> "x-connection-hash: 4f0bdc46b650bf3148c1dd8b5addfded\r\n"
-> "x-content-type-options: nosniff\r\n"
-> "x-frame-options: SAMEORIGIN\r\n"
-> "x-response-time: 180\r\n"
-> "x-runtime: 2.04E-4\r\n"
-> "x-transaction: d1e1d50fa37ffd5d\r\n"
-> "x-tsa-request-body-time: 1\r\n"
-> "x-xss-protection: 1; mode=block\r\n"
-> "\r\n"
reading 139 bytes...
-> ""
-> "\x1F\x8B\b\x00\x00\x00\x00\x00\x00\x00\xAAVJ-*\xCA/*V\xB2\x8A\xAEVJ\xCEOIU\xB2R\n\xF5s\f\r\xF1\xF0\x0F\xF2\x8Cru\x89wtvv\r\x0EV\xD2Q\xCAM-.NL\a\xC9\x87dd\x16+\x14\xA5\x16\x96\xA6\x16\x97(\x00\x99y\xF9%\n\x05E\xF9\x05\xA9E9\x95\n\x89\xA5%\x19\xA9y%\x99\xC9\x89%\xA9)J\xB5\xB1:JP\x95JV\xD5J\x05\x89E\x89\xB9@\xBB\xAAkkk\x01\x00\x00\x00\xFF\xFF\x03\x00C\xE56\xE5z\x00\x00\x00"
{"errors":[{"code":"UNAUTHORIZED_ACCESS","message":"This request is not properly authenticated"}],"request":{"params":{}}}read 139 bytes
Conn close

#6

Hi, I’m also getting the same error. Any update on this issue?


#7

@mcaravind @tholmes There was a bug that was fixed on 5/18. If you are unable to create a campaign now, it would be a separate issue. When was the last time that you were able to create a campaign successfully in the sandbox?

I’ll be following up on this issue in this thread: Creating an ad campaign in the sandbox


#8

@tholmes: did this ever work for you? I’m seeing the same response now - I’m new to the Twitter API world and I’m not sure if I’m doing the right thing. Do I need to setup a funding instrument on the sandbox api account?
Here’s the call I’m making:

twurl -H https://ads-api-sandbox.twitter.com /0/accounts/gq0wxx/campaigns -d '{"name": "trialAdCampaign_API", "funding_instrument_id": "if4ny", "start_time": "2015-06-10T00:00:00Z", "end_time": "2015-06-11T00:00:00Z", "daily_budget_amount_local_micro": 5000000, "account_id": "gq0wxx", "paused": true}' -t

And here’s the response:

{"errors":[{"code":"UNAUTHORIZED_ACCESS","message":"This request is not properly  authenticated"}],"request":{"params":{}}}

Thanks for your help!


#9

Thanks, I will try again soon in the sandbox w/ twurl. As a side note I am able to make campaigns on the production API using ruby code. I’ve stopped using twurl since I hit this problem.

@saurako You should see a funding instrument already created in the sandbox. Funding instruments are not able to be created via the API.


#10

Ahh, understood. Thanks @tholmes!

I did find the correct funding_instrument_id for the sandbox. But the response still says that the request is not properly authenticated.


#11

I am having the same problem, requests to create a Campaign are failing (I wasnt even able to run basic requests before). Im getting this:

{
“errors”: [
{
“code”: “UNAUTHORIZED_ACCESS”,
“message”: “This request is not properly authenticated”
}
],
“request”: {
“params”: {}
}
}

I have supplies all 4 mandatory parameters.


#12

@SocialOpinions: did you correctly encode the parameters? This error can appear from this too.