Reputation: 1
Whenever I input an @ symbol I get an error instead of the empty list of roles that I would expect. The method being roles()
and the last part of the URL being the input parameter. I need to use the @ symbol as I want to use email addresses as the input parameter.
TERMINAL COMMAND: curl --header 'Accept: application/json' --header 'Authorization: Bearer b85f73f2-f2fb-3a92-9066-d0af4d6a50eb' 'https://apitst.linkedsystems.uk/account/v1/user/roles/oeoe' OUTPUT: {"Roles":[]}
TERMINAL COMMAND WITH '@' SYMBOL: curl --header 'Accept: application/json' --header 'Authorization: Bearer b85f73f2-f2fb-3a92-9066-d0af4d6a50eb' 'https://apitst.linkedsystems.uk/account/v1/user/roles/oeoe@' OUTPUT: 404Status reportRuntime ErrorNo matching resource found for given API Request
Any idea how to alter the API so that it allows @ symbols as input parameters?
I've tried changing the carbon.xml
& user-mgt.xml
but no luck.
Any help is much appreciated. Thanks.
Upvotes: 0
Views: 459
Reputation: 425
You have two options to use the '@' sign in your API
ex: curl --header 'Accept: application/json' 'http://localhost:8280/testapi/user/test%40gmail.com'
<api xmlns="http://ws.apache.org/ns/synapse" name="testAPI" context="/testapi">
<resource methods="GET" uri-template="/user/{email}">
<inSequence>
<payloadFactory media-type="json">
<format>{ "id": 1, "email": "$1"}</format>
<args>
<arg evaluator="xml" expression="get-property('uri.var.email')"/>
</args>
</payloadFactory>
<respond/>
</inSequence>
</resource>
</api>
ex: curl --header 'Accept: application/json' 'http://localhost:8280/testapi/user/[email protected]'
Upvotes: 2
Reputation: 274
The problem here is, you are not urlencoding the data you are sending. If you are using curl to invoke the API, change the curl command as follows,
curl -G --header 'Accept: application/json' --header 'Authorization: Bearer b85f73f2-f2fb-3a92-9066-d0af4d6a50eb' 'https://apitst.linkedsystems.uk/account/v1/user/roles/oeoe@' -k
Replace the token value with the new token and it should do the trick.
Upvotes: 0