We had an issue a couple of days ago where two points of failure caused some downtime and so I spent most of today revisiting all my monitors to give us as much warning as possible if one of our services fails.
One particular API I set up lives on the as400 (iSeries) and operates off of it’s ZendCore server in PHP. I quickly scripted a page to verify: connection between ZendCore PHP and db2, that the connection to that endpoint was in fact SSL, and on what port.
The PHP code is very simple and returns a JSON string that looks like this:
The slight problem today was figuring out how to get Site 24×7 to not just verify the link, but check the JSON values and verify it is what I need. If not, then send the alert. In this case, I want to verify AS400CONNECTION is true and SSL is true.
Site 24×7 suggests using a REST API monitor and then asserting the value in JSONPath. I was completely new to this and finding a good clean example was a bit tough, hopefully this saves someone some time. Here’s …
I’ve recently been curious about switching to a time API for my time stamps and removing any dependency the app might have on the server for a timestamp. Upon Googling I found some paid services, some free and of the free ones, I noticed one was hosted on Heroku. I’ve heard of Heroku, but never had a reason to attempt to use it. This was the perfect chance.
How I Created a Small “GetTime” API
First, I created a free account on Heroku, nothing special. After verifying my email, I logged in to my Heroku Dashboard and up on the right hand corner, selected Create New App. I named it my company-api and out popped an app.
I decided on just plain, legacy PHP and a simple DateTime string passed thru JSON encode, just to get started. No authentication, no timezone, just a simple spit out if a request to the site came, like this:
$DateTime = new DateTime();
$currentTime = $DateTime->format("Y-m-d H:i:s");
I created a Git repo for this brand new file and pushed it out. Then, I went back to Heroku, Dashboard, My App and Deploy. I selected Github as my deploy “resource” …
The API mentioned in my first tutorial got taken down and so I had to do some updates. First, choose another 3rd party API. I currently am trying out HTML 2 PDF Rocket and modified my code a bit:
public async Task<FileStreamResult> PrintAsync(int id)
InvoiceVM invoiceVM = new InvoiceVM();
invoiceVM = invoiceRepository.Get(id);
var engine = new RazorLightEngineBuilder()
.UseFilesystemProject(_hostingEnvironment.WebRootPath + "\\pdf\\")
var view = await engine.CompileRenderAsync("PDF.cshtml", invoiceVM);
string apiKey = "xxxxxxxxxxxxxxxxxxxx";
using (var client = new WebClient())
// Build the conversion options
NameValueCollection options = new NameValueCollection();
MemoryStream ms = new MemoryStream(client.UploadValues("http://api.html2pdfrocket.com/pdf", options));
return new FileStreamResult(ms, "application/pdf");
This is based directly off the HTML 2 Rocket documentation. For the rest of the code see the first tutorial.
I recently had an issue with printing a report to PDF using Microsoft Reporting Service and a RDLC file, etc. Something similar to this. Unfortunately, it worked great in development, but refused to work once deployed into Azure. No matter what I did, I could not duck the GDI errors I kept getting, and apparently this continues through a line of various PDF exporting extensions, all of which rely on GDI for export. Turns out, I’m not alone in facing this problem and so, I decided to find a solution.
My general idea was to use something to render my PDF view, send that view as one long html string to a free PDF microservice and get the PDF in return.…
TLDR: post IS successful. PayTrace, by design, returns a 400 error, which sets off exceptions in httpresponse. Solution: catch the exception and then continue deserializing your response.
I coded a few weeks ago a .NET post to the PayTrace API which helps me demo and test payment by credit card using client side encryption. The process more or less went like this:
- Create demo account as a merchant on Paytrace
- Download PEM key
- On submit of form with credit card information, an imported PayTraceJS library encrypts the card number and csc code
- Use the demo account’s username and password to submit a request for a token
- Submit transaction (which includes encrypted info as well as other required fields) using token and await response
A successful http response returns a status code of 200. I read it via stream, deserialize it using json into my CardResponse object (both successful and failure responses have the same design). Everything went great until I began testing rejected cards.…
This is a very basic tutorial on dealing with Payeezy, who’s documentation I found sometimes difficult. Some of this guidance, I only found in forum threads and so I document…
Get What You Need
- Merchant Demo account
- Developer Sandbox account
- Merchant Token (demo)
- API secret (sandbox)
- API key (sandbox