Encountering an issue while attempting to make an API GET request using JSON and Python

Encountering an issue with my API get request using JSON RESTful services and Python3. Any assistance would be greatly appreciated. The API instructions I am following can be found on this website . I have the CVE number already, as it's included in the URL below.

import requests
import json

response = requests.get('https://services.nvd.nist.gov/rest/json/CVE-2021-40463/1.0/').json()

print(response)

File "/Users/xxxx/Desktop/UT_Code/UT_Homework.py", line 4, in <module>
    response = requests.get('https://services.nvd.nist.gov/rest/json/CVE-2021-40463/1.0/').json()
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/requests/models.py", line 910, in json
    return complexjson.loads(self.text, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Answer №1

Incorrect URL provided. Please utilize:

https://services.nvd.nist.gov/rest/json/cve/1.0/CVE-2021-40463/

Here is the complete code snippet:

import requests
import json

response = requests.get('https://services.nvd.nist.gov/rest/json/cve/1.0/CVE-2021-40463')
data = response.json()
print(json.dumps(data, indent=4))

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for associating JSON reponses with button actions on a webpage?

I developed a JavaScript script that interacts with a Tableau server API to handle running jobs. The script presents the retrieved jobs on a web page, along with corresponding buttons that enable users to terminate specific jobs. While the script function ...

The Correct Approach for Implementing Error Handling in a Node.js API Server

In my Node.js API server, I encountered an issue with error handling. To tackle this problem, I developed a module specifically for error handling. When in development mode, this module sends JSON objects containing errors to the API client. Here is an exa ...

SQL JSON condition clause

I am currently working with a table that contains a column named PRICING_DATA, which is of type JSON. Here is an example: pricingJson type json nullable I have written an SQL query to retrieve data from this table based on the value of a specific key in ...

Please assist with utilizing the combination of Facebook SDK and JSON

After going through numerous discussions on this problem, I realized that none of them truly explains the issue at hand. To resolve the conflicts arising from using facebookSDK with JSON, one effective solution is to alter the names of the JSON classes ca ...

I am unsure whether Django or Drupal would be the best fit for my requirements

My interest lies in mastering either Drupal or Django to create dynamic websites with medium databases, multi-level users, PayPal integration, content management, fast development speed, and security features. I have a preference for MVC, ORM, and object-o ...

The ASP.NET MVC controller did not receive the JSON object properly due to some missing properties

I am facing an issue when trying to pass a JSON object to my ASP.NET MVC controller. The JSON is set in JavaScript in this way: jsonChildren = '{ "childImproItems" : [{ "Theme":"tralalali" }, { "Theme":"tralalali" }]}'; ... $.ajax({ ...

Determining if two numpy arrays are equivalent element-wise when containing floating point values

How can I determine if two numpy arrays are equivalent? Code: import numpy as np def numpy_equal(): x = np.array([2, 3, 1, 0.000000000000001000000000000000000000002]) y = np.array([2, 3, 1, 0.000000000000001000000000000000000000001]) #assert ...

Serve vast in-memory array using ESPAsyncWebServer

I am attempting to serve a sizable float array with 8192 values from the ESP32 Heap using the ESPAsyncWebServer library for ArduinoIDE. The microcontroller I'm using is an ESP32 devkit c, and my goal is to access the array through a web browser. Here ...

Looking to implement pyperclip functionality on Heroku platform

Is it feasible to utilize pyperclip on Heroku with a Selenium application in order to copy something to the clipboard? Since the platform utilizes a 'headless' browser and lacks a GUI, accessing the clipboard is challenging. Is there any way for ...

Issue: Incorrectly calling a hook. Hooks can only be used within the body of a function component. Assistance needed to resolve this issue

import React, { useState } from "react"; const RegistrationForm = () => { const [name, setName] = useState(""); const [password, setPassword] = useState(""); const [email, setEmail] = useState(" ...

When using google search with json_decode, the result returned is null

$query = "Poultry meat is a major source of animal protein considering"; function fetch_google($query) { $cleanQuery = str_replace(" ","+",$query); $url = 'http://www.google.com/search?q='.urlencode($cleanQuery); $data=file_get_contents($url ...

Is there a clash between Angular JS $scope and the MIME content-type in an API's HTTP response?

While experimenting with an AngularJs app, I am consuming a REST API using Slim PHP through $http (and planning to use $resource next). The data retrieval from the API works perfectly when the controller is set up like this: angular .module("adminTall ...

showing four forms, unfortunately the last one is malfunctioning

Thank you for taking the time to read this. I've been working on a template that displays 4 forms, each with its own submit button triggering a POST request to the appropriate form. The first 3 forms are functioning correctly, but the last one (Estoq ...

The Kendo Grid is appearing correctly, however, it is not showing the JSON data as

Lately, I've been struggling with grids, particularly when trying to display properly formatted JSON data fetched from a webservice (which has already been validated in VS2013 and JSONLint). If someone could take a look at my solution and point out wh ...

Working with double de-referencing pointers in Python using Ctypes

One of my C functions resides in a DLL and has the following structure. ProcessAndsend(Format *out, // IN char const *reqp, // IN size_t reqLen, // IN Bool *Status, // OUT char const **r ...

Tips for utilizing the ng-filter Json [@attributes] with Angularjs

I'm trying to sort through sports feed based on sport ID, but the JSON feeds are structured with @attributes. JSON Feeds series: [ { @attributes: { id: "cdf590b4-0206-45b0-9122-20eae46a2b27", name: "Pakistan tour of Sri Lanka, 2015", year ...

Transforming C# code into Python programming language

Hello, I have created a web scraper using Selenium in C#, but now I need to convert it into Python for my project. I am having trouble displaying the element in the console window. Here is the C# code: var elements = ghostDriver.FindElements(By.XPath("/h ...

The loading of JSON data is unsuccessful in jqwidgets

Attempting to populate a jqwidgets grid with JSON Response. The grid loads with empty data and no errors are reported. Shown below is the JSON response along with the jQuery code. Can you spot what I might be missing? JSON DATA : {"holidayrule":["{&bso ...

Python program to split a URL

Just starting out with Python and learning the fundamentals. Question: I have a log file that contains requests to multiple pages, like the examples below: "GET /img/home/search-user-ico.jpg HTTP/1.1" "GET /SpellCheck/am.tlx HTTP/1.1" "GET /img/plan-co ...

When I attempt to read a JSON file using JSON SERDE, I am only fetching a single row

JSON Data: [{ "liked": "true", "user_id": "101", "video_end_type": "3", "minutes_played": "3", "video_id": "101", "geo_cd": "AP", "channel_id": "11", "creator_id": "101", "timestamp": "07/05/2019 01:36:35", "disliked": "true" }, { "lik ...