03-31-2022 05:36 AM
I have an restconf api i and not able to understand how to pass body in this.
This is my postman.
I have code which do check-sync , but i don't know how to pass body ({"outformat":"cli"}) to that code
import socket import _ncs from _ncs import maapi import traceback import json def get_traceback(e): lines = traceback.format_exception(type(e), e, e.__traceback__) return '--- '.join(lines) sock_maapi = socket.socket() # self.log.info('action NCS_PORT: ', _ncs.NCS_PORT) maapi.connect(sock_maapi,ip='127.0.0.1',port=_ncs.NCS_PORT) # maapi.load_schemas(sock_maapi) _ncs.maapi.start_user_session( sock_maapi,'admin','python',[],'127.0.0.1', _ncs.PROTO_TCP) ns_hash = _ncs.str2hash("http://tail-f.com/ns/ncs") results = maapi.request_action(sock_maapi, [], ns_hash, "/pycheck-sync-containtest:a/ntp:ntp{ntp2-default}/check-sync")
How to pass body?
And can you provide some docs which tell how to convert restconf Api to maapi code?
03-31-2022 05:48 AM
@himanss4 on your Postman client, run the API call and then on the right side of Posstamn click the `</>` symbol, you can select Python request from the languages, this will display the API requests into Python.
Hope this helps.
03-31-2022 07:33 AM - edited 03-31-2022 07:34 AM
@bigevilbeard I want to use maapi python code. What you are telling that is http calls from python code. But NSO has inbuild maapi package which can do same thing , I have already written that pls check above , I want how to pass body in that. I know http call in python by i want to leverage maapi package of NSO
03-31-2022 09:46 AM
03-31-2022 09:45 PM - edited 03-31-2022 09:46 PM
Hi @vleijon Maagic and Maapi is all new for me. I got more example in maapi then maagic api. I am good if maagic api does that work more easily.
Any example you have for above thing?
Do you have any good blog where maagic api implementation is provided for POST request ?
03-31-2022 10:12 PM
04-01-2022 05:06 AM
work like charm
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide