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

Can't get the "Subscribe a user to a product" call right #6

Open
woutercx opened this issue Mar 9, 2016 · 3 comments
Open

Can't get the "Subscribe a user to a product" call right #6

woutercx opened this issue Mar 9, 2016 · 3 comments

Comments

@woutercx
Copy link

woutercx commented Mar 9, 2016

Hi,
I'm trying to subscribe a user to a product (add a subscription) with a PUT call. But I keep getting a "400 BAD REQUEST", which has to do with the userId and productId fields. I got the correct ids because I made calls to the get users and get products before. So I know how to use the Azure API Management REST API. Too bad your management samples don't contain samples for all the calls (I'd like to have examples for the PUT calls too).
REQUEST: (numbers have been changed of course):

PUT /subscriptions/361296af6f48a5263c91b0eb?api-version=2014-02-14-preview HTTP/1.1
Connection: close
Content-Length: 228
Content-Type: application/json
Authorization: SharedAccessSignature uid=663252382f83fe019d040003&ex=2016-11-24T01:12:00.0000000&sn=BUOr1j1uO8PnHja20UNeTWkE5z/dtgJw0DKTCybY+JLEF0OZ2aqCQBOU0Cg4FWzejTyUW1tMjBF9jd9WRRENew==
Host: [OUR APIM INSTANCE].management.azure-api.net

{
"userId": "users/4633a02dc1dd7b1240b60882",
"productId": "products/56bc8a99b9668d0cb078c2e5",
"state": "active",
"primaryKey": "aedf306ba80f4058b0e0e82439c11a91",
"secondaryKey": "f1d9ad0c091d4a7c92091447c336dd44"
}

RESPONSE:
{"error":{"code":"ValidationError","message":"One or more fields contain incorrect values:","details":[{"code":"ValidationError","target":"userId","message":"Invalid field 'userId' specified"},{"code":"ValidationError","target":"productId","message":"Invalid field 'productId' specified"}]}}

@woutercx
Copy link
Author

woutercx commented Mar 9, 2016

Found it by debugging with Paw and reverse engineering the Azure PowerShell module "AzureRM.ApiManagement\1.0.5".
It should be /users/4633a02dc1dd7b1240b60882 and /products/56bc8a99b9668d0cb078c2e5
The API Management REST documentation is wrong in this regard..

@upendra1588
Copy link

Hi @woutercx ,

have you resolved this issue? I am facing same while accessing rest api using C# code. Please share

Thanks
Upendra

@woutercx
Copy link
Author

woutercx commented Sep 5, 2018

Hi, yes I have resolved the issue, the solution is in comment that I posted above (Mar 9, 2016).

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