6 Comments
User's avatar
Diary Farm's avatar

Thanks for the article. I found it helpful, but I’m still a bit unclear on a few points. When comparing your article with the official ABP documentation on static C# API clients, I didn’t notice many differences.

What I’m particularly interested in is how to configure third party APIs using ABP’s features. For instance, let’s say I want to consume a Token Metrics API that requires sending an api-key in the request header. While this is straightforward with HttpClient, I’d like to know how to achieve the same using ABP's built-in capabilities.

Would you consider updating the blog post to include an example like that? It would really help developers looking to fully leverage ABP when working with external APIs.

Expand full comment
Engincan Veske's avatar

Thanks for your comment. I'll try to update the post when I have time but in the meantime, if you want to apply your scenario, then you can configure the `AbpHttpClientBuilderOptions`, add a new HTTP Message Handler, and pass the API-key.

See https://gist.github.com/EngincanV/d5aba003db762040051c518da50fff2a for a demonstration.

Expand full comment
Engincan Veske's avatar

Okay, can you check that if the remote service url is correct or not on the test project? Because there was a bug relates to that, it was pointing localhost:3000 for all the time. It's fixed now, but your template might be old, i assume.

Expand full comment
Tu Trong's avatar

Thanks for this post. But I am facing the error at Test project's ClientDemoService

public async Task RunAsync()

{

var output = await _profileAppService.GetAsync();

.........

}

Can not GetAsync();

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Please explain and help me to solve this issue.

P/S: I already run the Web project before.

Thanks and Best Regards

Expand full comment
Engincan Veske's avatar

Ensure, in your HttpApi.Client project you have the following config:

```

context.Services.AddHttpClientProxies(

typeof(MyProjectNameApplicationContractsModule).Assembly,

RemoteServiceName

);

```

Expand full comment
Tu Trong's avatar

Thank you for you promptly reply,

But of course, I have fully configured

context.Services.AddHttpClientProxies(

typeof(MyProjectNameApplicationContractsModule).Assembly, RemoteServiceName

);

Any thing else missing?

Expand full comment