TM1 Rest API – CRUD App – 2nd Chapter
https://coursework.vschool.io/content/images/2017/06/CRUD.jpg

TM1 Rest API – CRUD App – 2nd Chapter

This article is a continuation of the 1st chapter and it will discuss on POST operation of TM1 Rest API. Also, this whole series is to show the capability of TM1 rest api with a non-native front end (reactjs) as many have queried after the first chapter that this functionality exists in new version of PAW. Moreover, I have also been asked how these API calls are made and how to decipher the API functions – my simple answer is to reverse engineer the TM1py code (has great commentary!!!) and with basic python knowledge you can easily understand each rest API call.

Continuing from chapter 1 inside of chore-list js; we can see the below code which we could see as “Create” button which is disabled at first.

No alt text provided for this image

The button has a onclick function “createClikcked”. This function calls createChore function in api-service.js.

createChore function accepts two arguments (Body and Token) for the POST command to work. The body takes the name of the new chore supplied in the input field and token is used as the header(covered in the next chapter)

No alt text provided for this image

Let’s pause here and check out how the same API call works from Postman. In Postman we would select POST and send body and headers as below. However, if you see in reactjs, we are passing only {name} without key; this is because of internal functionality of javascript with json – if both the key and value have same name, it is ok to pass value. If we have more list of body to send it can be sent as arguments for example: {Name, DSTSensitive, Active}

No alt text provided for this image

Our application will also look as below.

No alt text provided for this image

Coming next - Update, Delete and Login Routing

Christoph Hein

Managing Director at Intito | Expert in Finance & Sustainability Planning | TM1 Fanboy | Advocate for a Sustainable Future

3 年

Great beginners guide. Love to see other languages used to query #tm1. Hopefully this way we can improve #tm1py as well. We need more packages like that for the different languages out there.

要查看或添加评论,请登录

Akram Ali的更多文章

社区洞察

其他会员也浏览了