I have installed the Volo.Abp.Http.Client.IdentityModel package in the Host module of Service A and configured it in HttpApi.HostModule.cs as outlined in the documentation.
Please share your code and appsettings configuration
Please confirm if the appsettings below look correct, and I will proceed to share the code. appsettings.json (Service A)
"RemoteServices": {
"Default": {
"BaseUrl": "https://localhost:44325"
},
"ServiceB": {
"BaseUrl": "https://localhost:44371/",
"UseCurrentAccessToken": true
}
},
"IdentityClients": {
"Default": {
"GrantType": "client_credentials",
"ClientId": "AdministrationService",
"ClientSecret": "1q2w3e*",
"Authority": "https://localhost:44322",
"Scope": "Service B"
}
},
Here is a similar question, can you share your code
https://abp.io/support/questions/2803/VoloAbpHttpClientAbpRemoteCallException-Unsupported-Media-Type
After modifying it at the controller level, it worked. However, I am still unable to access CurrentUser in Service B. Additionally, the Service B method is only triggered when I annotate the API method with AllowAnonymous. I have installed the Volo.Abp.Http.Client.IdentityModel package in the Host module of Service A and configured it in HttpApi.HostModule.cs as outlined in the documentation.
you can check this document to know how to add a custom filter.
https://abp.io/docs/latest/framework/infrastructure/data-filtering
I have already gone through the documentation when i try to keep the below code in dbcontext getting no suitable method to overload error on CreateFilterExpression method
protected bool IsBranchFilterEnabled => DataFilter?.IsEnabled<IBranchEntity>() ?? false;
protected int? CurrentBranchId => BranchContext?.CurrentBranchId;
protected override bool ShouldFilterEntity<TEntity>(IMutableEntityType entityType)
{
if (typeof(IBranchEntity).IsAssignableFrom(typeof(TEntity)))
{
return true; // Apply filter to all entities implementing IBranchEntity
}
return base.ShouldFilterEntity<TEntity>(entityType);
}
protected override Expression<Func<TEntity, bool>> CreateFilterExpression<TEntity>(ModelBuilder modelBuilder)
{
var expression = base.CreateFilterExpression<TEntity>(modelBuilder);
if (typeof(IBranchEntity).IsAssignableFrom(typeof(TEntity)))
{
// Build the filter for BranchId
Expression<Func<TEntity, bool>> branchFilter = e =>
!IsBranchFilterEnabled ||
(EF.Property<int?>(e, "BranchId") == CurrentBranchId || EF.Property<int?>(e, "BranchId") == null);
// Combine the new filter with existing filters
expression = expression == null ? branchFilter : QueryFilterExpressionHelper.CombineExpressions(expression, branchFilter);
}
return expression;
}