Skip to content

Commit 7a66cbd

Browse files
fix(dotnet): update SDK to point to /v1/request (#405)
* fix(dotnet): update SDK to point to /v1/request This is an updated API endpoint, we're deprecating the version-less one. * chore(dotnet): add TODO for later when we upgrade deps Fix version of RestSharp to v1.0.6 for the dotnet v6 example app This was breaking due to a deprecated interface * docs(dotnet): add some better example values to the test apps The lack of a `context.Request.Headers["key"];` when requesting the test server over GET was causing the requests to not be set. Lets just hardcode this for the example app.
1 parent e092c1b commit 7a66cbd

File tree

9 files changed

+12
-9
lines changed

9 files changed

+12
-9
lines changed

Readme/ConstValues.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ public static class ConstValues
66
public static readonly string version = "1.0.2";
77
public static readonly int wait = 0;
88
public static readonly string receive = null;
9-
public static readonly string readmeApiEndpoints = "https://metrics.readme.io/request";
10-
9+
public static readonly string readmeApiEndpoints = "https://metrics.readme.io/v1/request";
1110
}
1211
}

Readme/HarJsonTranslationLogics/ReadmeApiCaller.cs

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ public async Task<string> SendHarObjToReadmeApi()
2727
string apiKey = "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(_apiKey + ":"));
2828
request.AddHeader("Authorization", apiKey);
2929
request.AddParameter("application/json", _harJsonObject, ParameterType.RequestBody);
30+
// TODO when we upgrade RestSharp to v1.0.7, this interface has been deprecated
31+
// https://restsharp.dev/v107/#body-parameters=
32+
// We should update this to:
33+
// var response = await client.ExecuteAsync(request);
3034
IRestResponse response = await client.ExecuteAsync(request);
3135
return response.Content;
3236
}

ReadmeMetricsAPI3/Startup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3737
//Or extract apikey from request body form or x-www-form-urlencoded by key as
3838
// req.Form["key"];
3939

40-
context.Items["apiKey"] = context.Request.Headers["key"];
40+
context.Items["apiKey"] = "apiKey";
4141
context.Items["label"] = "username / company name";
4242
context.Items["email"] = "email";
4343
await next();

ReadmeMetricsAPI3/appsettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"AllowedHosts": "*",
1010
"readme": {
11-
"apiKey": "This is Readme API",
11+
"apiKey": "This is your ReadMe API Key",
1212
"options": {
1313
"allowList": [],
1414
"denyList": [ "password", "secret", "private" ],

ReadmeMetricsAPI5/Startup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3737
//Or extract apikey from request body form or x-www-form-urlencoded by key as
3838
// req.Form["key"];
3939

40-
context.Items["apiKey"] = context.Request.Headers["key"];
40+
context.Items["apiKey"] = "apiKey";
4141
context.Items["label"] = "username / company name";
4242
context.Items["email"] = "email";
4343
await next();

ReadmeMetricsAPI5/appsettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"AllowedHosts": "*",
1010
"readme": {
11-
"apiKey": "This is Readme API",
11+
"apiKey": "This is your ReadMe API Key",
1212
"options": {
1313
"allowList": [],
1414
"denyList": [ "password", "secret", "private" ],

ReadmeMetricsAPI6/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//Or extract apikey from request body form or x-www-form-urlencoded by key as
2020
// context.Request.Form["key"];
2121

22-
context.Items["apiKey"] = context.Request.Headers["key"];
22+
context.Items["apiKey"] = "apiKey";
2323
context.Items["label"] = "username / company name";
2424
context.Items["email"] = "email";
2525
await next();

ReadmeMetricsAPI6/ReadmeMetricsAPI6.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ItemGroup>
1010
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
1111
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
12-
<PackageReference Include="RestSharp" Version="107.0.2" />
12+
<PackageReference Include="RestSharp" Version="106.13.0" />
1313
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
1414
</ItemGroup>
1515

ReadmeMetricsAPI6/appsettings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"AllowedHosts": "*",
99

1010
"readme": {
11-
"apiKey": "This is Readme API",
11+
"apiKey": "This is your ReadMe API Key",
1212
"options": {
1313
"allowList": [],
1414
"denyList": [ "password", "secret", "private" ],

0 commit comments

Comments
 (0)