## TL;DR

Turns out Microsoft's documentation was wrong and you're supposed to just use your account key as the password in the request instead of the encoded string. ``` require 'net/http' accountKey [your value] url = 'https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Web?Query=%27xbox%27&$top=50&$format=json' uri = URI(url) req = Net::HTTP::Get.new(uri.request_uri) req.basic_auth '', accountKey res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl =&gt; uri.scheme == 'https'){|http| http.request(req) } puts res.body ``` Okay, after an hour of frustration I figured out a way to do it.

## Fix

1. Turns out Microsoft's documentation was wrong and you're supposed to just use your account key as the password in the request instead of the encoded string. ``` require 'net/http' accountKey [your value] url = 'https://api.datamarket.azure.com/Data.ashx/Bing/SearchWeb/v1/Web?Query=%27xbox%27&$top=50&$format=json' uri = URI(url) req = Net::HTTP::Get.new(uri.request_uri) req.basic_auth '', accountKey res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl =&gt; uri.scheme == 'https'){|http| http.request(req) } puts res.body ```
   Expected: You get the expected result; the problem is gone.

## When to use

- You are dealing with this situation.
- The symptom matches: Bing Search API in Ruby.

## When NOT to use

- Unrelated issues with a different cause.
- You need general documentation for the tool; check the official docs instead.

## Compatibility

Reported per the linked source.

## Variant phrasings

### Bing Search API in Ruby

## Why it happens

Stack Overflow #13660455 (accepted answer, 7 votes, 3 answers): I read the "Bing Search API - Quick Start" but I don't know how to make this http request in Ruby (Weary) How to translate "Stream_context_create()" in Ruby? And What does it mean? "Bing Search API - Quick Start" I would want to use a Ruby sdk but those I found are deprecated ex (Rbing) https://github.com/mikedemers/rbing Do you know a up-to-date Wrapper for Bing Search API (Web only results)?

## Edge cases

- If your error message differs even slightly, this is probably a different issue; search the exact text.
- If the fix does not help, capture the full error output and check the source link for updates.