How to map the API publisher query parameter values to the Backend URL resource path in WSO2 API M - wso2-api-manager

I need to map the API publisher query parameter values to backend URL resource path. I have the API publisher URL be like
"https://102.20.10.3:8245/srno/v1.0/studentRecordNo?user_id=test29"
and the Backend URL like
"http://localhost:8280/services/getStudRecNo.HTTPEndpoint/getsrno/{uri.var.user_id}"
When i execute in swagger , i am getting error like below
{
"Fault": {
"Code": "",
"Reason": "DS Code: VALIDATION_ERROR\nNested Exception:-\njavax.xml.stream.XMLStreamException: DS Code: VALIDATION_ERROR\nSource Data Service:-\nName: getStudRecNo\nLocation: \\getStudRecNo.dbs\nDescription: get student unique id\r \r \r \nDefault Namespace: http://ws.wso2.org/dataservice\nCurrent Request Name: _getgetsrno_user_id\nCurrent Params: {user_id={studentRecordNo,test29}}\nNested Exception:-\nScalar type expected\nField Name: user_id\nField Value: {studentRecordNo,test29}\n\n",
"Detail": ""
}
}
Please help me.

Related

Can't create stack from template using Openstack Heat API

I'm trying to create a stack from a template using the Heat API. I'm using the API reference here as a guide. I have the following json in a file called single-server-template.json:
{
"stack_name": "api-test",
"template": {
"heat_template_version": "rocky",
"description": "Testing Heat API\n",
"resources": {
"server1": {
"type": "OS::Nova::Server",
"properties": {
"name": "Server1",
"image": "Ubuntu 22.04 (Jammy)",
"flavor": "alt.st1.small",
"key_name": "my_key",
"networks": "Internal"
}
}
}
}
}
I'm sending it with this: curl -X POST -H "X-Auth-Token:$OS_TOKEN" -d #single-server-template.json https://$OS_HOST_URL:8004/v1/$OS_PROJECT_ID/stacks
I've been at it for hours but no matter what I send I get a 400 error:
{"code": 400, "title": "Bad Request", "explanation": "The server could not comply with the request since it is either malformed or otherwise incorrect.", "error": {"type": "HTTPBadRequest", "traceback": null, "message": "The server could not comply with the request since it is either malformed or otherwise incorrect."}}
Things I've tried:
confirmed my environment vars are filled in correctly before sending
confirmed that the template itself is valid by spinning it up from the UI console
confirmed that other endpoints that require auth work as expected
screaming and/or crying
Can anyone confirm that what I've got is correct, or test it against your own openstack instance? The only other thing I can think of is that maybe my openstack provider has an issue with their API

Issues with startAt in orderBy timestamp - Firebase REST API

Im using the Firebase REST API to retrieve data with the GET method, this is the URL im executing:
const url = `https://firestore.googleapis.com/v1/projects/${projectId}/databases/${dataBase}/documents/${collectionName}/${documentId}?&key=${apiKey}&pageSize=${pageSize}&pageToken=${nextPageToken}&orderBy=timestamp&startAt=${startTime}`;
But it return this error:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"startAt\": Cannot bind query parameter. Field 'startAt' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"startAt\": Cannot bind query parameter. Field 'startAt' could not be found in request message."
}
]
}
]
}
}
If im omitting the paramemeter of startAt it works fine.
The format of startTime, id try it in all the following ways, and all return the same error:
Firebase return format: 2022-06-16T15:46:46.061Z
Unix Timestamp:1655394406
ISO 8601 date: 2022-06-16T15:46:46+00:00
What im doing wrong?
(For reference here is the official documentation where the startAt is explained)
You're calling the Firestore REST API, but are referencing the documentation for the REST API of the Realtime Database. While both products are part of Firebase, they are complete separate - and the API of one cannot be applied to the other.
For the documentation of the Firestore REST API, see https://firebase.google.com/docs/firestore/reference/rest

MS Graph API v1.0 cannot filter by onPremisesSamAccountName using Python requests

I'm attempting to use Python + requests to talk with MS Graph API (v1.0) in order to filter user objects by the onPremisesSamAccountName property but am receiving this error when sending the simple query:
endpoint = "https://graph.microsoft.com/v1.0/users"
query_parameters = {
'$filter': 'onPremisesSamAccountName eq \'somevalue\'',
'$select': 'id,displayName,mail,onPremisesSamAccountName'
}
user_graph_data = requests.get(
endpoint,
headers={'Authorization': 'Bearer ' + result['access_token']},
params=query_parameters
).json()
==============================
{
"error": {
"code": "Request_UnsupportedQuery",
"message": "Unsupported or invalid query filter clause specified for property 'onPremisesSamAccountName' of resource 'User'.",
"innerError": {
"date": "...",
"request-id": "...",
"client-request-id": "..."
}
}
}
I am able to filter using this field while using Microsoft's Graph Explorer:
https://developer.microsoft.com/en-us/graph/graph-explorer and the corresponding Javascript call in the developer console shows a successful call and response based on the filter with onPremisesSamAccountName.
The MS Graph docs for v1.0 state that this is a supported field for filtering as well:
Returned only on $select. Supports $filter (eq, ne, NOT, ge, le, in,
startsWith).
I'm also able to successfully filter using other fields such as 'mail' (i.e. changing the $filter string from 'onPremisesSamAccountName eq \'somevalue\'' to 'mail eq \'somevalue\'' works just fine, so I don't believe this is a syntactical error)

LinkedIn API request fails with "Unpermitted fields present in RESOURCE_KEY: Data Processing Exception while processing fields [/memberId]"

I'm trying the following request:
GET https://api.linkedin.com/v2/people/(id:urn:li:person:<person id>)?oauth2_access_token=<token>&projection=(results*(localizedFirstName,vanityName))
But I always get a:
{
"serviceErrorCode": 100,
"message": "Unpermitted fields present in RESOURCE_KEY: Data Processing Exception while processing fields [/memberId]",
"status": 403
}
If I try to do it using the alternative API:
GET https://api.linkedin.com/v2/people?ids=List((id:urn:li:person:<person id>))&oauth2_access_token=<token>&projection=(results*(localizedFirstName,vanityName))
An Internal Server Error is returned:
{
"message": "Internal Server Error",
"status": 500
}
I'm using Google Chrome to perform those requests.
I tried using Postman too.
Headers:
X-Restli-Protocol-Version: 2.0.0
Authorization: Bearer <token>
Got:
{
"serviceErrorCode": 0,
"message": "Syntax exception in path variables",
"status": 400
}
My app permissions are:
r_emailaddress
r_ads
w_organization_social
rw_ads
r_basicprofile
r_liteprofile
r_ads_reporting
r_organization_social
rw_organization_admin
w_member_social
I tried other APIs (socialActivity, ugcPosts) and everything looks fine.
I checked my API usages at https://www.linkedin.com/developers/apps/<id>/usage and people usage is currently 0%.
The tested user profiles are also public.
You should only use the id (instead of the urn). also the fields projection is wrong:
Use:
projection=(localizedFirstName,vanityName)
Instead of:
projection=(results*(localizedFirstName,vanityName))
As example:
curl -H "X-Restli-Protocol-Version: 2.0.0" \
"https://api.linkedin.com/v2/me?oauth2_access_token=<TOKEN>&projection=(id)"
Will return
{
"id": <ID>
}
and use it as:
curl -H "X-Restli-Protocol-Version: 2.0.0" \
"https://api.linkedin.com/v2/people/(id:<ID>)?oauth2_access_token=<TOKEN>&projection=(localizedFirstName,vanityName)"
So:
{
"vanityName": "<VANITY-NAME>",
"localizedFirstName": "<NAME>"
}
Hope this help
id parameter needs only person_id but you are providing urn.Try this https://api.linkedin.com/v2/people/(id:person_id) and don't forgot to include X-RestLi-Protocol-Version:2.0.0 in header while making call.

Using nginx to redirect dynamic request

I have a druid service which runs at my local machine at port 8082 as follows:
Method POST: http://localhost:8082/druid/v2/?pretty
Body:
{
"queryType" : "topN",
"dataSource" : "some_source",
"intervals" : ["2015-09-12/2015-09-13"],
"granularity" : "all",
"dimension" : "page",
"metric" : "edits",
"threshold" : 25,
"filter": {
"type": "and",
"fields": [
{
"type": "selector",
"dimension": "pix_id",
"value": "1234"
}
}
}
Hitting this query gives me a list of records based on the value of the dimension 'pix_id'.
Now, I want to setup an nginx such that the external application should not have any clue about my druid service. I just want the external application to hit the URL:
http://localhost:80/pix_id/98765
This url should dynamically generate a JSON with the above mentioned pix_id and send a request to druid and return the response to the user.
Is it possible to do this in nginx?
Yes you can do this, but rather I would suggest to have a php or python script in between to give the results.
So the setup would be -
Have php page receive the request.
make a curl call from php to the druid, locally.
get the result and pass on the response.
There are multiple benefits of doing this eg. -
You completely mask druid, and not necessarily limited to druid.
You can do more calculations in php before sending the request to druid.
caching at php end.

Resources