API calls in custom component are failing for external users
Hello,
I have developed a custom component using remote module. its working fine for internal users.. but when I logged in as external user, all the APIs of my custom component are failing with 404 status code..
How do I fix this? TIA
Like
Configuration services exposed to external users need to have two changes:
First of all, the C# service itself needs to have the following attributes on the class:
[DefaultServiceRoute]
[SspServiceRoute]You'll likely also need to add the using directives:
using Terrasoft.Web.Common;
using Terrasoft.Web.Common.ServiceRouting;Second of all, the url path to the service is different for external users.
Full Creatio (internal) users will use:
0/rest/UsrMyService/SomeMethodExternal users will use:
0/ssp/rest/UsrMyService/SomeMethodYou can use the following code, if needed, to get the correct path/url based on the user type, it will return the correct path for both user types:
var workspaceBaseUrl = Terrasoft.utils.uri.getConfigurationWebServiceBaseUrl();
var servicePath = workspaceBaseUrl + "/rest/UsrMyService/SomeMethod";
//servicePath will now contain the correct URL for either user typeRyan
Ryan Farley,
Oops.. its not working..
the api path for internal users:
https://11007053-demo.creatio.com/0/rest/UsrCwService/CwGetRecordById
external users api path:
https://11007053-demo.creatio.com/0/ssp/rest/UsrCwService/CwGetRecordById
The external path looks good but still giving 404..
Sagar Rodda,
I assume you did also add the attributes to the C# service class and recompile? (Note, those are attributes for the class, not the method)
namespace Terrasoft.Configuration
{
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using Terrasoft.Core;
using Terrasoft.Web.Common;
[DefaultServiceRoute]
[SspServiceRoute]
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class UsrSourceCode1 : BaseService
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public string SayHelloTest(string Name)
{
return "Hello " + Name + "!";
}
}
}Sagar Rodda,
Or can combine as:
[DefaultServiceRoute, SspServiceRoute]Ryan Farley,
Yeah, I overlooked the class part.. I added the attributes to methods that's why it was not working.. now its fixed.. thank you so much