Sharepoint REST API: Get items from a list. If they do not exist, retrieve the ListItemEntityTypeFullName value from the List. All with one call

I have a small app that, when initialized, fetches information from a Sharepoint list through a REST call.

That information should eventually be modified from within the application, again through the REST API, and saved in the same List.
That is why, when I originally get that information, I also store the ListItemEntityTypeFullName value of the List in a global scope variable, which will then be passed in the POST function.

My code to get the list items is as follows:

    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items",
        type: "GET",
        headers: {"Accept": "application/json;odata=verbose"}
    }).done(function(data) {
        listType = data.d.results(0).__metadata.type
    });

If no item is found, the only way I know how to store the ListItemEntityTypeFullName value would be to make a second ajax call as follows:

    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/?$select=ListItemEntityTypeFullName",
        type: "GET",
        headers: {"Accept": "application/json;odata=verbose"}
    }).done(function(data) {
        listType = data.d.ListItemEntityTypeFullName
    });

Now my question is: is there a way to make both requests in a single call, so if no items were found in the List, can I still get the ListItemEntityTypeFullName value somewhere? I am trying to optimize the amount of calls I have to make to keep the application fast and smooth.

Thank you!

Rest API with dynamic types

Which API design is better and why?

1]

[
    {
        "group": {
            "id": 1314395,
            "title": "My Group"
        }
    },
    {
        "event": {
            "id": 1398209,
            "description": "My Event"
        }
    }
]

two]

[
    {
        "type": "group"
        "object": {
            "id": 1314395,
            "title": "My Group"
        }
    },
    {
        "type": "event"
        "object": {
            "id": 1398209,
            "description": "My Event"
        }
    }
]

I prefer the second, because of automation with Moshi, but I'm missing more arguments to convince my colleagues;] Do you know of any good open APIs that are using the second convention over the first?

Python code that interacts with the rest API

Please help me with the code review of a simple Python function that interacts with the rest API

def submit_notebook():
    job_submit_url = "some_url"
    authorization_header = "Some token"
    path = "some_path"
    temp_run_id_file = "file_name"
    submit_response = requests.post(url=job_submit_url, json=job_submit_dict,
                                    headers={"Content-Type": "application/json", "Authorization": authorization_header})
    if submit_response.status_code == 200:
        submit_response_json = submit_response.json()
        if "run_id" in submit_response_json:
            run_id = submit_response_json("run_id")
            logging.info("Run ID is:" + str(run_id))
            with open(path + temp_run_id_file, 'w') as file:
                file.write(str(run_id))
            return run_id
        else:
            logging.info(json.dumps(submit_response_json.json()))
            raise Exception("Got a bad response.")

php – How do I get all comments per post via WP REST API?

I am busy trying to understand how WP REST API works in combination with React. When I review the WP REST API documentation, it confuses me a bit.

Comments

For example, here, it appears that you have to specifically give the id of a post in the query to retrieve the post. Can't we use a variable for this? If so, how could this be done? And how could we ensure that by post we automatically get your feedback below as well?

I mean, this gets all the comments:

https://example.com/wp-json/wp/v2/comments

But it won't let me combine this with the posts. How do we relate them to each other?

Another example:

https://example.com/wp-json/wp/v2/posts?categories=33

It would mean that we search for post categories with ID = 33, but how can we make this generic? I like it https://example.com/wp-json/wp/v2/posts?categories=$GET_POST_ID more or less?

rest api: Magento web API that provides internal server errors to add products

I tried to post a product on my Magento site through its REST web API. I am using curl. I have this error:

{"message": "Internal error. Details are available in the Magento log file. Report ID: webapi-5e884238b420f"}

And when I searched the log file, I found:

/var/www/html/var/log/exception.log:(2020-04-04 08:15:52) main.CRITICAL: Report ID: webapi-5e884238b420f; Message: Property "ShowDefaultNotificationMessage" does not have accessor method "setShowDefaultNotificationMessage" in class "MagentoCatalogInventoryApiDataStockItemInterface". {"exception":"(object) (Exception(code: 0): Report ID: webapi-5e884238b420f; Message: Property "ShowDefaultNotificationMessage" does not have accessor method "setShowDefaultNotificationMessage" in class "Magento\CatalogInventory\Api\Data\StockItemInterface". at /var/www/html/vendor/magento/framework/Webapi/ErrorProcessor.php:208, LogicException(code: 0): Property "ShowDefaultNotificationMessage" does not have accessor method "setShowDefaultNotificationMessage" in class "Magento\CatalogInventory\Api\Data\StockItemInterface". at /var/www/html/vendor/magento/framework/Reflection/NameFinder.php:100)"} ()

I tried to find out what this error meant. I couldn't find much.

This is my curl request:

curl -X POST "http://167.179.118.154/index.php/rest/default/V1/products"  -H "Content-Type:application/json" -H "Authorization: Bearer " -d '{"product":{"id":0,"sku":"string","name":"string","attribute_set_id":0,"price":0,"status":0,"visibility":0,"type_id":"string","created_at":"string","updated_at":"string","weight":0,"extension_attributes":{"website_ids":(0),"category_links":({"position":0,"category_id":"string","extension_attributes":{}}),"stock_item":{"item_id":0,"product_id":0,"stock_id":0,"qty":0,"is_in_stock":true,"is_qty_decimal":true,"show_default_notification_message":true,"use_config_min_qty":true,"min_qty":0,"use_config_min_sale_qty":0,"min_sale_qty":0,"use_config_max_sale_qty":true,"max_sale_qty":0,"use_config_backorders":true,"backorders":0,"use_config_notify_stock_qty":true,"notify_stock_qty":0,"use_config_qty_increments":true,"qty_increments":0,"use_config_enable_qty_inc":true,"enable_qty_increments":true,"use_config_manage_stock":true,"manage_stock":true,"low_stock_date":"string","is_decimal_divided":true,"stock_status_changed_auto":0,"extension_attributes":{}},"bundle_product_options":({"option_id":0,"title":"string","required":true,"type":"string","position":0,"sku":"string","product_links":({"id":"string","sku":"string","option_id":0,"qty":0,"position":0,"is_default":true,"price":0,"price_type":0,"can_change_quantity":0,"extension_attributes":{}}),"extension_attributes":{}}),"configurable_product_options":({"id":0,"attribute_id":"string","label":"string","position":0,"is_use_default":true,"values":({"value_index":0,"extension_attributes":{}}),"extension_attributes":{},"product_id":0}),"configurable_product_links":(0),"downloadable_product_links":({"id":0,"title":"string","sort_order":0,"is_shareable":0,"price":0,"number_of_downloads":0,"link_type":"string","link_file":"string","link_file_content":{"file_data":"string","name":"string","extension_attributes":{}},"link_url":"string","sample_type":"string","sample_file":"string","sample_file_content":{"file_data":"string","name":"string","extension_attributes":{}},"sample_url":"string","extension_attributes":{}}),"downloadable_product_samples":({"id":0,"title":"string","sort_order":0,"sample_type":"string","sample_file":"string","sample_file_content":{"file_data":"string","name":"string","extension_attributes":{}},"sample_url":"string","extension_attributes":{}}),"giftcard_amounts":({"attribute_id":0,"website_id":0,"value":0,"website_value":0,"extension_attributes":{}})},"product_links":({"sku":"string","link_type":"string","linked_product_sku":"string","linked_product_type":"string","position":0,"extension_attributes":{"qty":0}}),"options":({"product_sku":"string","option_id":0,"title":"string","type":"string","sort_order":0,"is_require":true,"price":0,"price_type":"string","sku":"string","file_extension":"string","max_characters":0,"image_size_x":0,"image_size_y":0,"values":({"title":"string","sort_order":0,"price":0,"price_type":"string","sku":"string","option_type_id":0}),"extension_attributes":{"vertex_flex_field":"string"}}),"media_gallery_entries":({"id":0,"media_type":"string","label":"string","position":0,"disabled":true,"types":("string"),"file":"string","content":{"base64_encoded_data":"string","type":"string","name":"string"},"extension_attributes":{"video_content":{"media_type":"string","video_provider":"string","video_url":"string","video_title":"string","video_description":"string","video_metadata":"string"}}}),"tier_prices":({"customer_group_id":0,"qty":0,"value":0,"extension_attributes":{"percentage_value":0,"website_id":0}}),"custom_attributes":({"attribute_code":"string","value":"string"})},"saveOptions":true}'

Is it because my JSON contains dummy data (which I just copied from the Magento web API documentation)? But I tried to modify some of the values ‚Äč‚Äčlike below, and still got the same answer:

{
  "product": {
    "id": 10,
    "sku": "phone8",
    "name": "iPhone8",
    "attribute_set_id": 0,
    "price": 10,
    "status": 0,
    "visibility": 0,
    "type_id": "string",
    "created_at": "string",
    "updated_at": "string",
    "weight": 0,
    "extension_attributes": {
      "website_ids": (
        0
      ),
      "category_links": (
        {
          "position": 0,
          "category_id": "string",
          "extension_attributes": {}
        }
      ),
      "stock_item": {
        "item_id": 0,
        "product_id": 0,
        "stock_id": 0,
        "qty": 0,
        "is_in_stock": true,
        "is_qty_decimal": true,
        "show_default_notification_message": true,
        "use_config_min_qty": true,
        "min_qty": 0,
        "use_config_min_sale_qty": 0,
        "min_sale_qty": 0,
        "use_config_max_sale_qty": true,
        "max_sale_qty": 0,
        "use_config_backorders": true,
        "backorders": 0,
        "use_config_notify_stock_qty": true,
        "notify_stock_qty": 0,
        "use_config_qty_increments": true,
        "qty_increments": 0,
        "use_config_enable_qty_inc": true,
        "enable_qty_increments": true,
        "use_config_manage_stock": true,
        "manage_stock": true,
        "low_stock_date": "string",
        "is_decimal_divided": true,
        "stock_status_changed_auto": 0,
        "extension_attributes": {}
      },
      "bundle_product_options": (
        {
          "option_id": 0,
          "title": "string",
          "required": true,
          "type": "string",
          "position": 0,
          "sku": "string",
          "product_links": (
            {
              "id": "string",
              "sku": "string",
              "option_id": 0,
              "qty": 0,
              "position": 0,
              "is_default": true,
              "price": 0,
              "price_type": 0,
              "can_change_quantity": 0,
              "extension_attributes": {}
            }
          ),
          "extension_attributes": {}
        }
      ),
      "configurable_product_options": (
        {
          "id": 0,
          "attribute_id": "string",
          "label": "string",
          "position": 0,
          "is_use_default": true,
          "values": (
            {
              "value_index": 0,
              "extension_attributes": {}
            }
          ),
          "extension_attributes": {},
          "product_id": 0
        }
      ),
      "configurable_product_links": (
        0
      ),
      "downloadable_product_links": (
        {
          "id": 0,
          "title": "string",
          "sort_order": 0,
          "is_shareable": 0,
          "price": 0,
          "number_of_downloads": 0,
          "link_type": "string",
          "link_file": "string",
          "link_file_content": {
            "file_data": "string",
            "name": "string",
            "extension_attributes": {}
          },
          "link_url": "string",
          "sample_type": "string",
          "sample_file": "string",
          "sample_file_content": {
            "file_data": "string",
            "name": "string",
            "extension_attributes": {}
          },
          "sample_url": "string",
          "extension_attributes": {}
        }
      ),
      "downloadable_product_samples": (
        {
          "id": 0,
          "title": "string",
          "sort_order": 0,
          "sample_type": "string",
          "sample_file": "string",
          "sample_file_content": {
            "file_data": "string",
            "name": "string",
            "extension_attributes": {}
          },
          "sample_url": "string",
          "extension_attributes": {}
        }
      ),
      "giftcard_amounts": (
        {
          "attribute_id": 0,
          "website_id": 0,
          "value": 0,
          "website_value": 0,
          "extension_attributes": {}
        }
      )
    },
    "product_links": (
      {
        "sku": "string",
        "link_type": "string",
        "linked_product_sku": "string",
        "linked_product_type": "string",
        "position": 0,
        "extension_attributes": {
          "qty": 0
        }
      }
    ),
    "options": (
      {
        "product_sku": "string",
        "option_id": 0,
        "title": "string",
        "type": "string",
        "sort_order": 0,
        "is_require": true,
        "price": 0,
        "price_type": "string",
        "sku": "string",
        "file_extension": "string",
        "max_characters": 0,
        "image_size_x": 0,
        "image_size_y": 0,
        "values": (
          {
            "title": "string",
            "sort_order": 0,
            "price": 0,
            "price_type": "string",
            "sku": "string",
            "option_type_id": 0
          }
        ),
        "extension_attributes": {
          "vertex_flex_field": "string"
        }
      }
    ),
    "media_gallery_entries": (
      {
        "id": 0,
        "media_type": "string",
        "label": "string",
        "position": 0,
        "disabled": true,
        "types": (
          "string"
        ),
        "file": "string",
        "content": {
          "base64_encoded_data": "string",
          "type": "string",
          "name": "string"
        },
        "extension_attributes": {
          "video_content": {
            "media_type": "string",
            "video_provider": "string",
            "video_url": "string",
            "video_title": "string",
            "video_description": "string",
            "video_metadata": "string"
          }
        }
      }
    ),
    "tier_prices": (
      {
        "customer_group_id": 0,
        "qty": 0,
        "value": 0,
        "extension_attributes": {
          "percentage_value": 0,
          "website_id": 0
        }
      }
    ),
    "custom_attributes": (
      {
        "attribute_code": "string",
        "value": "string"
      }
    )
  },
  "saveOptions": true
}

What will Woocommerce REST API issue 401?

https://www.example.com/wp-json/wc/v3/orders?consumer_key=123&consumer_secret=abc is working when entered in the browser but fails with CURL with error
{"code": "woocommerce_rest_cannot_view", "message": "Sorry, you cannot list resources", "data": {"status": 401}}

rest: API issues image, empty file, or corrupted image download

What I am trying to achieve is this.

I am working on an integration web application that allows our technicians to extract data from our CRM and Sharepoint.

What I would like to be able to do is show sharepoint images in this web application. I think I have 2 options.

  1. I can create anonymous links to those images programmatically and then call them online.

  2. Pull them down locally and show them that way.

Since there are only a few images, I am leaning towards 2. So what I don't understand is how to extract them as they are binary.

I have been using the shareplum library. I can easily display a text file like:

from shareplum import Site
from shareplum import Office365
from shareplum.site import Version

server_url = "https://xxx.sharepoint.com/"
site_url = "sites/Technicians/"

un = "un"
pw = "pw"

authcookie = Office365(server_url, username=un, password=pw).GetCookies()
site = Site(server_url + site_url, version=Version.v2016, authcookie=authcookie)

folder = site.Folder('Shared Documents/Technical client documentation' 
                     '/Clients/Company Name, Inc/System Information')
p = folder.get_image('test.jpg')

Then from the library we have.

def get_file(self, file_name):
    response = self._session.get(self.site_url + f"/_api/web/GetFileByServerRelativeUrl('{self.info('d')('ServerRelativeUrl')}/{file_name}')/$value")
    return response.text

I added my own function:

def get_image(self, file_name):
    response = self._session.get(self.site_url + f"/_api/web/GetFileByServerRelativeUrl('{self.info('d')('ServerRelativeUrl')}/{file_name}')/$value")
    print(response)
    if response.status_code== 200:
        with open('/home/bruce/test_scripts/pictestNew.jpg', 'wb') as f:
            #response.raw.decode_content = True
            shutil.copyfileobj(response.raw, f)
    return "ok"

I am stuck trying to save the image. The above code gives me empty files. I also tried to return the response tex by doing the following:

p = folder.get_image('test.jpg')
p = bytearray(p)

P would be the returned answer, then:

with open('picOut1.jpg', 'wb') as f:
    f.write(p)

That gives me an image file of the correct size but throws a:

Error interpreting the JPEG image file (not a JPEG file: starts with 0xef
0xbf

I also posted this on Stackoverflow (StackOverflow question that I know is frowned upon, but my reasoning is this. Here I hope someone can tell me if I can do what I want. The other is just doing I'm sure I'm not messing up the python. Honestly, I don't know where the problem is at the moment.

This is my first Python run and I guess I am doing something wrong here. Would it be easier to create a public link to that image?

API Rest relationship design – Software Engineering Stack Exchange

I have a question regarding relationship design in REST APIs. Imagine I have a relationship like in this diagram

diagram

Now should I show the relationship in the team end point like this?

/v1/teams/:id

{
    id: "66e08a2b-2495-4edc-a528-ef00a3f908f1",
    name: "Sales",
    description: "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce tellus odio, dapibus id fermentum quis, suscipit id erat".
    members: [
        {
            id: "a31604c6-2289-4a0b-9127-7219abf4f494",
            name: "John Doe",
            role: "manager"
        },
        {
            id: "fa3c68f4-2008-4bd3-8280-8ae8c4c40a26",
            name: "James Smitt",
            role: "member"
        },
        {
            id: "946d2c3d-415c-4461-850d-892385a65f86",
            firstName: "Jane Doe",
            role: "member"
        }
    ]
}

And a employee end point like this:

/v1/employees/:id

{
    id: "a31604c6-2289-4a0b-9127-7219abf4f494",
    name: "John Doe",
    teams: [
        {
            id: "66e08a2b-2495-4edc-a528-ef00a3f908f1",
            name: "Sales",
            role: "manager"
        },
        {
            id: "66e08a2b-2495-4edc-a528-ef00a3f908f1",
            name: "Account management",
            role: "member"
        },

    ]
}

Or should I have a separate endpoint for teammembers?

/v1/teams/:id/members

[
    {
        id: "a31604c6-2289-4a0b-9127-7219abf4f494",
        name: "John Doe",
        role: "manager"
    },
    {
        id: "fa3c68f4-2008-4bd3-8280-8ae8c4c40a26",
        name: "James Smitt",
        role: "member"
    },
    {
        id: "946d2c3d-415c-4461-850d-892385a65f86",
        firstName: "Jane Doe",
        role: "member"
    }
]

And if I use the separate, should I include the teams Y members properties at employee and team endpoints?

rest – Spring, Kafka and Mongo how to create a RestController

I am learning to use Kafka, I have never used anything similar in the past. In my job, I was asked to create a POC and integrate it into Spring Boot and save information in MongoDB (because we will need to retrieve information on demand and thought that would be the best approach).

In the consumer I created an app, but I'm not sure if it should have a @RestController class or this is something that should come into Kafka and how.

Right now the code is working, but I would like to improve it, especially the controller part and any additional comments I can make to improve this.

This is the structure of my project:

enter the image description here

KafkaConfigurator

package com.example.demo.config;

import java.util.HashMap;
import java.util.Map;

import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
import org.springframework.kafka.support.serializer.JsonDeserializer;

import com.example.demo.model.User;

@EnableKafka
@Configuration
public class KafkaConfiguration {
    @Bean
    public ConsumerFactory consumerFactory() {
        Map config = new HashMap();

        config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "127.0.0.1:9092");
        config.put(ConsumerConfig.GROUP_ID_CONFIG, "group_id");
        config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
        config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);

        return new DefaultKafkaConsumerFactory<>(config);
    }

    @Bean
    public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory() {
        ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory();
        factory.setConsumerFactory(consumerFactory());
        return factory; 
    }

    @Bean
    public ConsumerFactory userConsumerFactory() {
        Map config = new HashMap();

        config.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "127.0.0.1:9092");
        config.put(ConsumerConfig.GROUP_ID_CONFIG, "group_id");
        config.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
        config.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);

        return new DefaultKafkaConsumerFactory<>(config, new StringDeserializer(), new JsonDeserializer<>(User.class));
    }

    @Bean
    public ConcurrentKafkaListenerContainerFactory userKafkaListenerFactory() {
        ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>();
        factory.setConsumerFactory(userConsumerFactory());
        return factory; 
    }
}

MyRestController

package com.example.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.listener.KafkaConsumer;
import com.example.demo.model.User;

@RestController
@RequestMapping(value = "users")
public class MyRestController {
    @Autowired
    private KafkaConsumer consumer;

    @GetMapping(path = "/findUserByOffset/{offset}")
    public User getUserByOffset(@PathVariable("offset") Long offset) {
        return consumer.getUserByOffset(offset);
    }

    @GetMapping(path = "/findUsersInRange/{lowerOffset}/{upperOffset}")
    public List getUsersByOffsetRange(@PathVariable("lowerOffset") Long lowerOffset, @PathVariable("upperOffset") Long upperOffset) {
        return consumer.getUsersByOffsetRange(lowerOffset, upperOffset);
    }
}

UserRepository

package com.example.demo.factory;

import java.util.List;

import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;

import com.example.demo.model.User;

public interface UserRepository extends MongoRepository{
    User findById(String id);
    User findByOffset(Long offset);

    @Query("{'offset' : { $gte: ?0, $lte: ?1 }}")
    List findInOffsetRange(Long lowerOffset, Long upperOffset);
}

KafkaConsumer

package com.example.demo.listener;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Service;

import com.example.demo.factory.UserRepository;
import com.example.demo.model.User;

@Service
public class KafkaConsumer {
    @Autowired
    UserRepository userRepository;

    @KafkaListener(topics = "Kafka_Example", groupId = "group_id")
    public void consume(String message) {
        System.out.println("Consumed message: " + message);
    }

    @KafkaListener(topics = "Kafka_Example_json", groupId = "group_json", containerFactory = "userKafkaListenerFactory")
    public void consumeJson(User user) {
        System.out.println("Consumed JSON message: " + user);
        userRepository.save(user);
    }

    public User getUserByOffset(Long offset) {
        return userRepository.findByOffset(offset);
    }

    public List getUsersByOffsetRange(Long lowerOffset, Long upperOffset) {
        return userRepository.findInOffsetRange(lowerOffset, upperOffset);
    }
}

User

package com.example.demo.model;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

@Document
public class User {
    @Id
    private String id;
    private String name;
    private String dept;
    private Long salary;
    private Long offset;

    public User(String id, String name, String dept, Long salary, Long offset) {
        super();
        this.id = id;
        this.name = name;
        this.dept = dept;
        this.salary = salary;
        this.offset = offset;
    }

    public User() {
        super();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDept() {
        return dept;
    }

    public void setDept(String dept) {
        this.dept = dept;
    }

    public Long getSalary() {
        return salary;
    }

    public void setSalary(Long salary) {
        this.salary = salary;
    }

    public Long getOffset() {
        return offset;
    }

    public void setOffset(Long offset) {
        this.offset = offset;
    }

    @Override
    public String toString() {
        return "User (name=" + name + ", dept=" + dept + ", salary=" + salary + ")";
    }
}

KafkaConsumerDemoApplication

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class KafkaConsumerDemoApplication {

    public static void main(String() args) {
        SpringApplication.run(KafkaConsumerDemoApplication.class, args);
    }

}

application.properties

#server
server.port=8081

#mongodb
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=app1

#logging
logging.level.org.springframework.data=debug
logging.level.=error

pom.xml



    4.0.0
    
        org.springframework.boot
        spring-boot-starter-parent
        2.2.5.RELEASE
         
    
    com.example
    kafka-consumer-demo
    0.0.1-SNAPSHOT
    kafka-consumer-demo
    Demo project for Spring Boot

    
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter
        
        
        
            org.springframework.boot
            spring-boot-starter-web
            2.2.6.RELEASE
        

        
            org.springframework.kafka
            spring-kafka
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
            
                
                    org.junit.vintage
                    junit-vintage-engine
                
            
        
        
            org.springframework.kafka
            spring-kafka-test
            test
        
        
        
            com.fasterxml.jackson.core
            jackson-databind
        
        
        
            com.fasterxml.jackson.core
            jackson-databind
        
        
        
            org.springframework.data
            spring-data-mongodb
            2.2.6.RELEASE
        


    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    


blockchain – Rest API for the transaction

I would like to create an application (java, spring) that returns information about a given transaction for a given txid (and specific vout). I would like it to work for both mainnet and testnet. I am looking for an API that does that.

For example, I wanted to use this to get that information:

https://rest.bitcoin.com/v3-alpha/blockchain/getTxOut/…………………………………………………………………………

but it returns me null all the time. Is there such an api?