How to use 'not equal' to filter on users attribute in a URL using REST Identity API in Bonita - rest

I'm using Bonita in a 7.3 Version. My goal is to use the identity API to gather information about my users, such as it's name etc. The thing is : I'm trying to catch all the users in a certain group of users with the following API request :
http://localhost:XXXXX/bonita/API/identity/user?a&f=role_id=101&f=manager_id=0
As we can imagin, this query gives me a list of users, with a role_id = 101 and no managers.
And then, I want to filter on a new attribute, which is the id : I d'ont want the user with the id equal to 101. I've tried this :
http://localhost:XXXXX/bonita/API/identity/user?a&f=role_id=101&f=manager_id=0&f=id!=101
But it does not work. Is it even possible to use the != element in Bonita ?

There is no != option within the f={filter name}={filter value}

Related

Salesforce SOQL to fetch all the accounts assigned to the logged in user

I have the accessToken of the logged in user and currently my query looks like below
https://xxx.salesforce.com/services/data/v45.0/query?q=SELECT Id,Name,Industry,Ownership,AnnualRevenue,NumberOfEmployees,Phone,Website FROM account ORDER BY LastModifiedDate DESC LIMIT 10
The above query will return last 10 modified accounts that the loggedin user has access to. What I want is to get only those accounts that are assigned to the logged in user.
You need a query similar to
SELECT Id, Name
FROM Account
WHERE OwnerId = '005...'
ORDER BY LastModifiedDate DESC
LIMIT 10
All users' ids in all SF instances in the world start with 005.
You can get the user id from the login success response. Which OAuth2 flow you've used? https://help.salesforce.com/articleView?id=sf.remoteaccess_oauth_user_agent_flow.htm&type=5 ?
In that example the user's id is hidden in the OAuth "id" field (identity, service that returns some info about the user. name, email, preferred language, locale, timezone...)
https://www.customercontactinfo.com/user_callback.jsp#
access_token=00Dx0000000BV7z%21AR8AQBM8J_xr9kLqmZIRyQxZgLcM4HVi41aGtW0qW3JCzf5xd
TGGGSoVim8FfJkZEqxbjaFbberKGk8v8AnYrvChG4qJbQo8&
refresh_token=5Aep8614iLM.Dq661ePDmPEgaAW9Oh_L3JKkDpB4xReb54_pZfVti1dPEk8aimw4Hr9ne7VXXVSIQ%3D%3D&
instance_url=https://yourInstance.salesforce.com&
id=https://login.salesforce.com%2Fid%2F00Dx0000000BV7z%2F005x00000012Q9P&
issued_at=1278448101416&
signature=miQQ1J4sdMPiduBsvyRYPCDozqhe43KRc1i9LmZHR70%3D&
scope=id+api+refresh_token&
token_type=Bearer&
state=mystate
It's bit hard to see but if you would receive this response you need to extract the 005x00000012Q9P part. If you don't trust parsing that url - well, call that "id" endpoint. See https://salesforce.stackexchange.com/q/11728/799 for response format and some more ideas.

Get specific product with id via Rest API Magento 2

I want to get the information from an specific product.
I am using this reference in this moment, and get all the products in given searchCriteria:
http://www.mysite.co/rest/V1/products-render-info?storeId=1&currencyCode=cop
Is there a way I can send the product id in the url and get only all its information?
You can add the filter
http://www.mysite.co/rest/V1/products?searchCriteria[filterGroups][0][filters][0][field]=entity_id&searchCriteria[filterGroups][0][filters][0][value]=1&searchCriteria[filterGroups][0][filters][0][condition_type]=eq
use field entity_id instead of id, value is product id here 1, condition_type is equal to here eq.
You can fetch product info by SKU, not ID.
API endpoint (get method) will pull product info. vendor/magento/module-catalog/etc/webapi.xml
/V1/products/:sku
So, your rest API calling URL should be like this
http://www.mysite.co/rest/V1/products/productsku
Note: If you want to fetch product info by id, you probably need to create a simple rest API. you can check this out.
https://magento.stackexchange.com/questions/282480/i-am-new-here-i-want-to-know-how-can-i-create-my-own-simple-api/282730

REST API parameter with multiple value types

I have the API route /api/users/:user_id, which takes a number as a parameter.
I want to have now the same route, but taking the username instead of the id, like this: /api/users/:username.
In my code, I have the route set up as /api/users/:user and I check the user URI parameter and do different actions if it is a number or a string.
Is it good practice / efficient to have the same route, but with a different parameter type? Both the username and user id's are unique.
It works, I just want to know if this is a practical solution, or if I should do separate routes.
we solved it by parsing the path variable.
psuedo code
long id;
String name;
try{
id = parselong(input);
}catch(parse exception){
name = input;
}
findbynameorid(id,name)
select * from customer where name = ? or id = ?
Assuming that both IDs and usernames are unique, it's valid solution.
Regarding implementation, you could use a regular expression to match the user identifier and check if it's an ID or a username.
It isn't really "good practice" to share a route parameter on a route, but as long as the IDs and usernames are both unique, you should be fine. Both act as unique identifiers for a user so both can be used to find the user in that route.
You can accept both the ID and username as the same parameter by first making the route param more permissive. Next, you can use the following (pseudo) query to look up whether that param matches the ID or the username:
SELECT id, name FROM users WHERE id={param} OR username={param}
Remember to pass that param in as a real query parameter; do NOT simply concatenate strings. Doing so will open you up to an SQL injection attack.
Solution
Make Parameter value as string and send one Request parameter as additional flag which describe request mode.
/api/users/:user_key?type=boolean > true(default) userid & false for username or vice versa.
Modify your api which then can answer two different apis
/api/users/user/userid/:id & /api/users/user/username/:name
Recommended
Above can resolve your issue. But is not recommended way of dealing with fetching user profile information using REST api. Presuming you will introduced user authentication in you rest application.
Self api : /api/users/me : this will fetch user info of the once who is currently logged with respect to that session/token.
User api : api/users/:id : this will fetch fetch specific user info
Username api: api/users?filters={username=some_username, }: this will fetch info of those users which have username matching with given filter.

Alfresco filter people by creator name

I want to modify the webscript alfresco-remote-api-5.0.d.jar\alfresco\templates\webscripts\org\alfresco\repository\person\people.get.js. I need to display for the connected user only user he has created.
I have modify the filter to include username in query.
filter = filter + " AND cm:creator:admin";
people.getPeoplePaging(filter, paging, sortBy, sortAsc);
This must display only users created by admin.
But it's not working(no user is returned).
How can i select only users created by a certain user ?
By looking at below definition of content model I sure , what you want to achieve is not possible ,as person(user) does not have creator property.Below link shows the content model for users.
https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/COMMUNITYTAGS/V4.2c/root/projects/repository/config/alfresco/model/contentModel.xml
https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/COMMUNITYTAGS/V4.2c/root/projects/repository/config/alfresco/model/systemModel.xml

Use Facebook API to list group members' join date and inviter

I can use the Facebook Graph API to get a list of group members. The simplest way to do this is to go to the Graph API Explorer and do a GET request of the form {group_id}/members. Is there a way to similarly obtain the members' join date and who they were invited by?
The relevant Graph API doc doesn't seem to mention it. But I know the information is stored by Facebook because it is possible to list all of the group members and their inviters through Facebook itself. Is there a way to get this information through the API?
EDIT: Nothing in the FQL group or group_member API either.
While this information is not available on the API, you can get it by using Selenium to scrape the members page.
First, instantiate a driver and use it to get the members page:
driver.gethttps://www.facebook.com/groups/your group number/members
Then, look for the member information:
containers = driver.find_elements_by_tag_name('td')
Finally, iterate through the web elements, extracting text and parsing resulting list for joined date information:
member_info = container.text.split('\n')
name = member_info[0]
member_since = member_info[-1]
You'll still have to map this information to the user ids, which you can do by looking for another element in the container and using REGEX.
`def parse_id(self, container, name):
hovercard = container.find_element_by_link_text(name).get_attribute('data-hovercard')
regex_id = re.compile('php\?id=(\d*)')
member_id = regex_id.search(hovercard).group(1)
return member_id`
It is indeed stored by Facebook and retrieved for use with internal APIs. For the Graph API however it is not possible to get this information.
All the fields available for a group_member are listed at SELECT column_name FROM column WHERE table_name = "group_member"