Clearing existing restFunctionService and API key question

6 views (last 30 days)
If I start a webservice rest API, how do I go about clearing it after it's finished/closed?
For example, let's create the service called "myService" that allows access to function addNumbers
service = restFunctionService("myService",["addNumbers"]);
I can run
service.close
or even
clear service
However, if I try to run
restFunctionService("myService",["addNumbers"]);
again MATLAB complains that "myService" already exists (in fact it's even still visible in the restFunctionServices dictionary). Only way to recreate the service is by restarting MATLAB.
Also, is there anyway to set the user API key manually or set it to null?

Answers (1)

Hitesh
Hitesh on 9 Apr 2025
Hi @Adan,
I too encountered the similar issue, you need to use following command before clearing the service. Since the service was still running in the memory that's why you were getting the error of "service already exists".
delete service
For better understanding of workflow of creating and using the "restFunctionService", refer to the following command Window image"

Products


Release

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!