Recently I had to build a small .NET client for an external API service. Unfortunately this service is fairly outdated and does not accept JSON input. Instead of dealing with the headache that is XML, I opted to use the tried-and-true HTTP form post.
I've done form posts before, but it's rare enough that I can never quite remember how to do it on the first (or second, or third) try. Instead of Googling around and piecing together a few different StackOverflow questions, I'm just going to post it here for posterity.
Take note: A very common failure point for sending this kind of request is not setting the proper ContentType header. If you don't set the ContentType header to e.g. "application/x-www-form-urlencoded", the receiving server is probably not going to accept your data and will likely throw an error.
I'm writing a book called The Shopify Development Handbook, and it's all about building rock-solid Shopify apps with C# and ASP.NET. If you haven't done so already, join the mailing list below by typing in your email address. I'll send you a free developer's guide on using the Shopify billing API to get paid for your app.
Learn how to build rock solid Shopify apps with C# and ASP.NET!
Did you enjoy this article? I wrote a premium course for C# and ASP.NET developers, and it's all about building rock-solid Shopify apps from day one.
Enter your email here and I'll send you a free sample from The Shopify Development Handbook. It'll help you get started with integrating your users' Shopify stores and charging them with the Shopify billing API.