REFACTOR to make json api for plntn request(raw code)