Pass a JSON request body using apex_web_service - oracle

May I ask if there is a way to pass a JSON request body using apex_web_service.make_rest_request?
The user we are using doesn't have privilege to use UTL_HTTP it returns "PLS-00201: identifier 'UTL_HTTP' must be declared" and I cannot do not have permission to change the privilege since I'm not an admin.

Of course, that is what the p_body parameter is for. Have a look into the API documentation of APEX_WEB_SERVICE.
https://docs.oracle.com/en/database/oracle/apex/22.1/aeapi/MAKE_REST_REQUEST-Function.html#GUID-C77BB45A-8968-470C-8243-BADB63743DE9

Related

Snowflake check query status fail with no default role

I am trying to design an executeQuerySynchronously() method. I first execute the query by make a POST request to execute the query Asynchronously, which returns a response including the statementhandle of that execution. I then keeps checking the status of that query by making a GET request to that statementHandle.
I was able to make the POST request, a response was successfully returned. However, I couldn’t make the GET request. And I got this error: “No default role has been assigned to the user, contact a local system administrator to assign a default role and retry.”
My question is:
1.Does a GET request absolutely need the role specified? If so, there’s nothing documented on Snowflake SQL API about specifying a role. The POST request has documentation however on specifying the role in request body. Or is it automatically assumed to use the default role?
2.Or is this error caused by other reason?
3.How do I solve this?
The user executing the query on Snowflake must have a role, either implicitly as their default role or defined explicitl

How to resolve unauthenticated issue in Postman GET Request

I used Laravel-8 for rest api. The route is shown below:
localhost:8888/myapp/server/api/v1/admin/role
It is a GET Request.
When I send it on POSTMAN, I got this error:
401Unauthorized
{
"message": "Unauthenticated."
}
In my route I have:
'middleware' => ['auth:api']]
The reason is because I don't know how to add the Login details. email: akwetey#gmail.com, password: mypass
How do I achieve this?
Thanks
This person walks you through the process nicely and should get you setup.
https://coding-lesson.com/api-authentication-with-laravel-passport/
Basically you need to:
Get to your login api, probably something like: localhost:8888/myapp/server/api/v1/login
Create a POST request to the login API, select the Body tab and define key values for you Email and Password
Then run the request and copy the AccessToken value from the results
Now with your API above, select the Authorization tab, choose Bearer Token as the Type and paste in your AccessToken value for the Token field
You should also go to your Headers table and define Accept and Content-Type keys, both with values of: application/json
Of course you'll want to then change all this to use variables after you get it right, so you don't have to keep repeating this with all your new API calls.
To fetch data behind protected routes you need to provide a token that will verify that the user who made the call is authenticated.
Then you have to provide the token in Authorization section of postman.
I assume you know the difference between Post and Get. Laravel works a little different then regular PHP, let me tell you how.
In order to access the protected routes you'll have to first access the token from login route. By sending the required data in .
Once that's done it'll return the token which can be used to access the protected routes under admin or auth middleware.
In your case you're accessing localhost:8888/myapp/server/api/v1/admin/role which is a protected route under admin middleware. You'll have to first access token and then send token with the get request to fetch the required data.

How to not accept query parameters from a post request in Laravel

I am doing a login via api using postman. But I noticed that it also accepts the query parameters when using POST method. I am not sure if this is the default way the Request works in Laravel so I would like to get some idea on how can I avoid on getting the data if it's being passed as query parameters. Basically I only want to process the login via api if the data is coming from the post body.
Thanks!
You can access only the parameters from query string by:
$request->query();
Similarly, you can access only the parameters from body by:
$request->post();

Cloud function authorization vs validationHandler

Found myself opening a couple of functions for access to users with invalid session tokens. The only way I could find to do that is to intercept the request using a bodyParser before Parse gets the request and removing sessionToken from the request.
Now trying to do a better job managing authorization to all functions - My question are:
can I relax the requirement that if a sessionToken is included it must be valid in any other way? Is session token validation done using a default validationHandler that can be replaced or is that done elsewhere?
to control access to cloud functions, is there anything like ACL roles? does cloud function's "validationHandler" accept only param? or can I inspect the user object as well?
Yes. In parse-server you can make sure that the sessions are valid because if you will try to run any CRUD operation with invalid session you will get http 403 error that your session is not valid or expired. You can control on the "Length" of your session by changing the sessionLength property in your parse-server app. The default is 1 year
There is no control access to cloud functions but you can check if a logged in user trigger this function by checking if the request.user is not undefined. Cloud functions can get only params in key-value pairs and those params cannot be Parse Objects. if you want to send ParseObject you can send the objectId of the parse object and then query for it in cloud code to get the full object. You can always access the user context in request.user (only if cloud code was triggered by the user). If you still want to "protect" your cloud code you can check if the calling user have a Role by query the Role DB and check if the user is contained there.

Add user to Yammer group, using API

I want to add a user to a group through the API. The proper endpoint should be:
https://www.yammer.com/api/v1/group_settings/process_additions , but keep getting a 404.
I found this, describing my exact problem, but no answers:
I want to join users except current login to yammer group. or I want to invite them to join yammer group using javascript sdk by yammer. I found one way of doing that by following
Makes a POST to: same call as above
id: GROUP_ID
invites[ids][]: USER_ID
invites[emails][addresses]:
I don't know how to call it. I tried to call that URI but it gave me error like
"No 'Access-Control-Allow-Origin' header is present on the requested resource" can any one tell me how to pass that data to request call ?
So: How to call https://www.yammer.com/api/v1/group_settings/process_additions ?
Looks like there is an authenticity_token param missing in your URL. You must supply that parameter.
This URL works, but note that it is not documented / supported, and could potentially change at any time:
https://www.yammer.com/insert_yammer_network_name/group_settings/process_additions/isert_groupID.json?id=isert_groupID&invites[ids][]=&invites[emails][addresses]=insert_email#domain.com&auto_add_invitees=true&authenticity_token=insert_oauth-token
Modify the above format with your details, copy it into a browser URL, hit enter, and you should get the following response {"status":"ok"}, or {"already_member":"true"} if the the user is already a member of the group.
Note that you can't make REST calls to https://www.yammer.com/* as it will result to CORS error. Use https://api.yammer.com/api/v1/ as your base URL instead.
===========================
The above solution is no longer valid. Use the impersonation method instead as it is supported/documented by yammer.

Resources