C#C
C#3y ago
Exilon

Custom cmdlet giving me a missing assembly error

Powershell gives me this error when I try run my cmdlet:
Get-UserFromId: Could not load file or assembly 'System.Net.Http.Formatting, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.

I'm using this guide to make API calls through this tutorial: https://stackoverflow.com/questions/9620278/how-do-i-make-calls-to-a-rest-api-using-c

which told me to add that assembly. When I compile it and use ipmo to add it to my powershell, I get that error when trying to run it. I was required to reference System.Net.Http.Formatting to get ReadAsAsync<>() to work (I think). Am I just building my project wrong?
Stack Overflow
This is the code I have so far:
public class Class1
{
private const string URL = "https://sub.domain.com/objects.json?api_key=123";
private const string DATA = @&q...
Was this page helpful?