Shane Bartholomeusz

Geek and lover of all things tech related

Tag: C#

Solved: Cognitive Services – Operation returned an invalid status code ‘Unauthorized’

Problem

The Azure Cognitive Services SDK is a set of pre-built services that enable developers to easily and quickly integrate AI capabilities into their applications. It provides a wide range of cognitive services including computer vision, language understanding, speech, and search APIs.

Recently whilst using the Azure Cognitive Services SDK recently, I encountered the below error while trying to consume the Cognitive Services Computer Vision API using the Dotnet SDK.

If you’ve also encountered the same error then you are in luck, because in this post I’ll share the solution that worked for me.

Operation returned an invalid status code ‘Unauthorized’

Continue reading

How To: Generate Swagger REST API Client

Overview

As the web continues to grow and evolve, API’s are where all the magic happens that powers this innovation. REST API’s have become increasingly more favoured by developers for their ease of use over other alternatives (XML I’m looking at you).

Unfortunately, REST API’s can sometimes become a bit unwieldy in terms of documenting them, and consuming them. It is for this reason that Swagger was born! Swagger will autogenerate documentation for your REST API in the form of an Open API specification (swagger.json) document (formerly Swagger Specification). This makes it much easier for developers to understand and consume an API.

Third-party developers can then use the swagger.json specification file to either manually create an API client or auto-generate one for the preferred language of choice.

In this post, I’ll show you how to autogenerate a C# REST API client from a swagger.json in a few easy steps.

Swagger Logo
Continue reading

Solved: Azure Functions Can’t Bind Parameter ‘data’ to Type Error

Problem

Recently I came across an unusual error whilst working with C# Azure Functions. When the Function was executed, the console window showed the following error.

The ‘XXXXXX’ function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method ‘XXXXXX ‘. Microsoft.Azure.WebJobs.Host: Can’t bind parameter ‘data’ to type ‘XXXXXX’.

I checked the Activity function parameter bindings however couldn’t see any obvious issue. However after some head scratching I eventually figured out the source of the issue …

In this post I’ll show you how to resolve this issue.

Azure Functions Logo
Continue reading

Visual Studio: Generate Class From JSON String

Overview

If you work JSON documents, I’m sure you’ve probably had to create a class file from a JSON string. Doing this manually can be a real pain in the proverbial, especially if you are working with a large JSON document. It can also be very error-prone. Therefore it’s best to automate this conversion.

In this post I’ll show you how to automatically generate a class file from a JSON string using a little known feature built into Visual Studio.

Visual Studio Icon
Continue reading

© 2024 Shane Bartholomeusz

Theme by Anders NorenUp ↑