Salesforce dsl component - apache-camel

For apex endpoint we use Salesforce component and frame to calls like this
.to("Salesforce:apexcall?ApexUrl=services/apexrest")
My query is how to frame toD using Salesforce components for sobjects endpoint
Https://salesforcedomain/service/data/v55.0/sobjects/{{attachment}}
I tried with different salesforce component but still doesn't work.

Related

How to Send Mail in Salesforce with Custom Code?

I have developed an apex class to send email using Exchange Web Services (only method allowed by my company). I have created a test flow to call the apex class and it works. Now i would like to send email through salesforce gui connecting the Send button to my apex class or calling my class when the send event is detected. is it possible? do you have any suggestions?

How to call internal APEX methods provided by B2B Commerce for Visualforce using REST request

Our team has a web application developed on top of B2B Commerce for Visualforce, there is a button on Product page, Add to Cart, it will call an Apex remote action method using Javascript when clicking on the button, I checked the network traffic in DevTools, found the following XHR request
the above XHR request should be made with the similar code
CCRZ.CloudCrazeView.addItem(event), there is the doc for the class, https://developer.salesforce.com/docs/atlas.en-us.b2b_commerce_dev_guide.meta/b2b_commerce_dev_guide/ccrz_CloudCrazeView.htm
does it have a REST API for the method in the picture? if yes any documentation or sources for it, so that I can call the method using HTTP REST requests, I mean calling it with curl, python or java remotely instead of Javascript.
the APEX class is ccrz.cc_RemoteActionController and the method is addItem, I know B2B Commerce provides a collection of REST API, REST API Endpoints for B2B Commerce for Visualforce, but this page doesn't include the method.
It's 2 different annotations and developer might have not used both. For Javascript usage it's #AuraEnabled and for being exposed as REST webservice it's #RestResource annotation on whole class + possibly #HttpPost on the method itself.
The problem is that in given class you can have only 1 of each HTTP "verbs" so if the class supports say 3 different buttons, they all would be accepting data as POST - problem. (in a pinch that dev could have done 1 master method inspecting the service url used, the input params and dispatching to right method for processing but it's bit meh...)
But. You should be able to patch that. Inspect cc_RemoteActionController in setup -> apex classes to confirm the method signature (it should be marked global meaning you can call it from apex too).
Create your own class that will act as REST wrapper
#RestResource(urlMapping='/HiStackoverflow/*')
global with sharing class HiStackoverflow{
#HttpPost
global static void addItem(Event e) {
ccrz.cc_RemoteActionController.addItem(e);
}
}

Correct way to consume 3rd party API with query in Django + React (Backend + Frontend)

I'm using Django on my backend and React on my frontend. I want to consume the OpenWeatherMap API. For security reasons, I want to keep my API key on the backend. Currently, I have this working on my Django app. When a POST request is made, the Django view renders the information required from OpenWeatherMap. How can the user type the query in React, send the query to to the backend and get the results on the frontend?
I have a very hacky way of doing this currently:
I POST (using axios) the city that the user enters in React to a REST API that I built in Django.
The backend queries the OpenWeatherMap API with the city that the user enters and POSTs the data that it gets from OpenWeatherMaps back to my API.
After this, the frontend uses a GET request on my API to show the information to the user.
I'm pretty sure this isn't the correct way to do this but I couldn't find any other questions on this, and I'm pretty new to web development.
First two steps are just fine. Instead of step 3. return the response from OpenWeather as a response to POST request from step 1. and resolve it in your React code.
On the second thought and to be fine with REST guidelines:
use GET to call your API with user's provided city name (POST is usually called to create a new resource - it's just a convention)
inside your API call OpenWeatherMap API with the city name
return the result to your React app as a response to GET from point 1.
More on REST API guidelines: https://restfulapi.net/

how to setup confirm email http post request with react-admin

I have an api method on the backend that confirms the user email (POST request), how can I consume this api with react-admin? I am new to the framework and all I see is consuming CRUD operations(create, list, update and delete).
Nothing stops you from accessing your API with fetch from your own component. If you want you can use some helpers the react-admin team has provided as fetchUtils.
Already shown how here under the EDIT 2 part.

inspite of mentioning allowed_client_ids in api declaration all web clients are able to access api

import endpoints
from protorpc import messages #for encapsulating data for sending
from protorpc import message_types
WEB_CLIENT_ID = '644515464936-552tgvthbmnhopg6qe71e99rrfbjatj7.apps.googleusercontent.com'
class HelloMessage(messages.Message):
msg = messages.StringField(1)
#endpoints.api(name='myapiversion1',
version='v1',
allowed_client_ids=[WEB_CLIENT_ID],
audiences=[WEB_CLIENT_ID],
scopes=[endpoints.EMAIL_SCOPE],
auth_level=AUTH_LEVEL_REQUIRED,
hostname='maulikversion1.appspot.com')
api url : https://maulikversion1.appspot.com/_ah/api/maulikversion1/v1/say_hello
I tried accesing it from www.hurl.it a web tool for testing rest api, and it was able to access the api.
Q1
what error it should give instead of allowing to access my custom api?
unfortunately it is allowing any web client to access api.
Q2.
AUTH_LEVEL_REQUIRED is not defined - internal server error
It is now restricting other web clients to access the api
I guess the client id generation took time to reflect at production-environment

Resources