","ws.op":"create"}', method: 'POST', uri" /> ","ws.op":"create"}', method: 'POST', uri" /> ","ws.op":"create"}', method: 'POST', uri"/>

Aweber: 'Missing required argument: [email]'

248 views Asked by At

hello Following is my request input for Aweber creating subscriber

{ body: '{"tags":[1,2],"email":"<email_id>","ws.op":"create"}',
  method: 'POST',
  uri: 'https://api.aweber.com/1.0/accounts/<accountID>/lists/<list id>/subscribers',
  headers: 
   { Authorization: 'OAuth oauth_consumer_key="<consumer key>",oauth_nonce="<oauth_nonce>",oauth_signature_method="<signature>",oauth_timestamp="<timstamp>",oauth_version="1.0",oauth_token="<token>",oauth_signature="<oauth signature>',
     'Content-Type': 'application/x-www-form-urlencoded' } }

I am passing email in body, but still getting error

{ error: 
 { status: 400,
 documentation_url: 'https://labs.aweber.com/docs/troubleshooting#badrequest',
 message: 'Missing required argument: [email]',
 type: 'MissingArgumentError' } }
2

There are 2 answers

0
Kaitlyn Chappell On

In AWeber's API the missing email errors mean exactly what they sound like, the email was missing from your request once it got to AWeber.

It sounds like things might not be encoded or included properly in your request. If you print out the request body before you send it what does it look like, is everything there? Are you sending the data with a content-type of application/json?

In addition, is the OAuth signature being formed correctly? We highly recommend the use of a library to help you out there. These will help you encode your request with all the proper signatures to make sure the data makes it to us correctly.

AWeber provides PHP and Python examples of creating a subscriber, and while you might not be using those languages you can perhaps use them to figure out where you went wrong. Those are available here: https://api.aweber.com/#tag/Manage-a-Subscriber

0
Jesús David Cárdenas Angulo On

I think maybe the problem is your 'Content-Type' header. According to docs Add subscriber you have to set headers this way:

headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
  'Authorization': "Bearer #{access_token}"
}

Using application/json instead of application/x-www-form-urlencoded but also 'Accept': 'application/json'. I just use x-www-form-urlencoded as part of Auth process with Oauth.

Hope this could help to someone