Community discussions

MikroTik App
 
ferdy1807
just joined
Topic Author
Posts: 4
Joined: Tue Jul 12, 2022 11:37 am

REST API Translate

Tue Jul 12, 2022 12:01 pm

Hi,
I need help :( for some command in JSON where CLI like this - POST
/ppp secret set name=yyy numbers=[find name=xxx]

or another way for solving update data like that
Your help is very much appreciated..
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7038
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: REST API Translate

Tue Jul 12, 2022 12:16 pm

You can run query with post
https://help.mikrotik.com/docs/display/ ... TAPI-Query

and then set
 
ferdy1807
just joined
Topic Author
Posts: 4
Joined: Tue Jul 12, 2022 11:37 am

Re: REST API Translate

Tue Jul 12, 2022 12:21 pm

https://IP/ppp/secret/set?numbers=[find name=xxx]
{"name" : "yyyy"}

I tried it at postman, it isnt works.
advice me how to translate here

numbers=[find name=xxx]
Last edited by ferdy1807 on Tue Jul 12, 2022 12:23 pm, edited 2 times in total.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7038
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: REST API Translate

Tue Jul 12, 2022 12:23 pm

You cannot run find via API. Look at the link provided above which shows how to run queries
 
ferdy1807
just joined
Topic Author
Posts: 4
Joined: Tue Jul 12, 2022 11:37 am

Re: REST API Translate

Tue Jul 12, 2022 12:28 pm

even though i put it inside query?
like this - POST body
{".query": [
"numbers=[find name=xxx]"
] }
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: REST API Translate  [SOLVED]

Tue Jul 12, 2022 12:33 pm

/ppp secret set name=yyy numbers=[find name=xxx]
correct script way
/ppp secret set [find where name=xxx] name=yyy
extended syntax
/ppp secret set numbers=[find where name=xxx] name=yyy

First, GET the .id:
/rest/ppp/secret/name?name=xxx&.proplist=.id
(for example *5 )

Then PATCH that .id setting the new name:
/rest/ppp/secret/*5
{"name": "yyy"}
 
ferdy1807
just joined
Topic Author
Posts: 4
Joined: Tue Jul 12, 2022 11:37 am

Re: REST API Translate

Tue Jul 12, 2022 2:57 pm

Ok sir got it,
So we must do it at 2 step

Hope next we get more detail about REST :)

Thanks for advice sir
 
cherlow
just joined
Posts: 1
Joined: Fri Aug 07, 2020 9:49 pm

Re: REST API Translate

Tue Dec 13, 2022 2:09 pm

I've tried patching on the ID to change the name but what ends up happening is that it creates a duplicate ppp secret entry with the name provided

Who is online

Users browsing this forum: Google [Bot], ko00000000001, mbezuidenhout and 20 guests