-3

Is there a way to send CoAP requests, like HTTP requests, using Python. I tried below one but I got many errors.

rec = reuest.get(coap://localhost:5683/other/block)
Aurora0001
  • 13,139
  • 5
  • 50
  • 53
  • I assume you meant `requests.get`? (from the [`requests`](http://docs.python-requests.org/en/master/) library). Be sure to edit to clarify, and include the error message you got for reference of future visitors. It isn't really relevant to the solution **this time**, but a [mcve] is always helpful to get a good answer. – Aurora0001 Jun 12 '17 at 15:04

1 Answers1

2

You can use a library such as CoAPython to act as a CoAP client:

from coapthon.client.helperclient import HelperClient

client = HelperClient(server=('127.0.0.1', 5683))
response = client.get('other/block')
client.stop()

The response is of type Response. The methods available on the response are listed in the documentation, which you must build yourself.

Since you haven't listed what you want to do with the response, you can use the documentation to find out the methods available and get the values you want.

Aurora0001
  • 13,139
  • 5
  • 50
  • 53