[SOLVED] Calling a Rest-API using C#

Issue

I’m trying to call a rest-api in asp.net to test if people are trustworthy with paying by invoice. The problem is that i’ve never used any rest-api before and couldn’t find a good example on how to call it in asp.net. Can someone help me?

Here are the values that the request needs.

enter image description here

/api/v1/RiskCube/claim

{
  "shopId": "20071992",
  "orderProcessId": "ref001",
  "ipAddress": null,
  "macAddress": null,
  "customerId": "cus001",
  "billingAddress": {
    "type": "Consumer",
    "businessName": null,
    "firstName": "Martin",
    "lastName": "Fr├╝h",
    "co": null,
    "street": "Funkenb├╝elstrasse",
    "houseNumber": "1",
    "postCode": "9243",
    "locationName": "Jonschwil",
    "country": "CH",
    "email": null,
    "phone": null,
    "dateOfBirth": null
  },
  "shippingAddress": null,
  "orderAmount": 1200
}

Solution

So, you can try out using HttpClient to call another API. Ex. https://docs.microsoft.com/ru-ru/aspnet/core/fundamentals/http-requests?view=aspnetcore-6.0 . And you can use libraries for that like Refit https://github.com/reactiveui/refit

edit: Link in english
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-6.0

Answered By – Serhii

Answer Checked By – Mary Flores (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *