Skip to content

Instantly share code, notes, and snippets.

@bobsilverberg
Last active December 15, 2015 04:09
Show Gist options
  • Select an option

  • Save bobsilverberg/5200021 to your computer and use it in GitHub Desktop.

Select an option

Save bobsilverberg/5200021 to your computer and use it in GitHub Desktop.
uri = "api/v1/product"
user = mozwebqa.credentials['default']
post_params = {
'username': user['name'],
'api_key': user['api_key'],
}
post_data = {
u'name': u'My Test',
u'description': u'My Description',
u'productversions': [ { u'version': u'v1' } ]
}
response = requests.post("%s/%s" % (mozwebqa.base_url, uri), params=post_params, data=post_data)
response.raise_for_status()
text = json.loads(response.text)
@klrmn

klrmn commented Mar 20, 2013

Copy link
Copy Markdown

the reason for that is you can't create a product without the first productversion. (and you should also use unicode)

post_data = {
u'name': u'My Test',
u'description': u'My Description',
u'productversions': [ { u'version': u'v1' } ]
}

the API doc does say productversions is required, but it doesn't provide an example...if i had a great idea how to write an example for it, i would.

@bobsilverberg

Copy link
Copy Markdown
Author

I updated it with that suggestions but am still seeing the same result: Product is not created and a list of 20 products is returned.

@klrmn

klrmn commented Mar 20, 2013

Copy link
Copy Markdown

oops, i forgot to tell you how to get the id!
id = response.headers['location'].split('/')[-2]

if the product isn't created, then i would expect there to be an error message in response.text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment