Accessing snap socket via rest api


#1

Hello All,

Greetings for the day!

I have a case like accessing another snap in a snap via its rest API’s.

I’m using nc command to GET/PUT Request. GET Request is working fine. But I couldn’t find out the syntax of using PUT.

Let me know if there are any solutions to this.

Thanks in advance.!!


#2

What are you doing, exactly? and which endpoint are you trying to reach?


#3

I’ve just realised you’ve asked this same question, and received answers that were apparently working, in

Enable/Disable systemd services

so what’s different? Why is this topic not that one?


#4

Hello @chipaca,

Just in simple words, this topic is created on how to send a PUT request over snap socket using nc command.


#5

which I’ve already shown you, with an example, which you said worked:

so what is it that doesn’t work, now?


#6

Hello @chipaca,

I have tried the same, but it doesn’t work!.

Below are my logs,

nc -U $SNAP_DATA/sockets/control << EOF
PUT /v1/configuration HTTP/1.0
Content-Length: 25
 
{"wifi.security":"open"}
EOF
HTTP/1.0 500 Internal Server Error
Date: Tue, 23 Apr 2019 14:10:10 GMT
Content-Length: 137
Content-Type: text/plain; charset=utf-8
{"result":{"kind":"internal-error","message":"Invalid method called"},"status":"Internal Server Error","status-code":500,"type":"error"}

#7

that looks like a correct PUT request, to a server that does not expect them.