Please, I need help.
I am beginner to apiato, I followed these instructions: "https://apiato.io/docs/9.x/miscellaneous/postman/#apiato-postman-api--environment" to test my API on postman, but I have a problem acces to API endpoint. Here is what postman shows me: "Error: getaddrinfo ENOTFOUND api.apiato.test"
求求你,我需要帮助。我是APIATO的初学者,我遵循了以下说明:“https://apiato.io/docs/9.x/miscellaneous/postman/#apiato-postman-api--environment”在邮递员上测试我的API,但我在访问API端点时遇到了问题。下面是邮递员向我展示的内容:“错误:getaddrinfo ENOTFOUND api.apiato.test”
I use VScode as editor and Laragon
我使用VScode作为编辑,使用Laragon
I followed these instructions: "https://apiato.io/docs/9.x/miscellaneous/postman/#apiato-postman-api--environment" to test my API on postman, but I have a problem acces to API endpoint. Here is what postman shows me: "Error: getaddrinfo ENOTFOUND api.apiato.test"
我按照以下说明操作:“https://apiato.io/docs/9.x/miscellaneous/postman/#apiato-postman-api--environment”在邮递员上测试我的api,但我在访问api端点时遇到问题。下面是邮递员向我展示的内容:“错误:getaddrinfo ENOTFOUND api.apiato.test”
I use VScode as editor and Laragon
我使用VScode作为编辑,使用Laragon
更多回答
This may not be the solution, but the creator has a postman collection you can import, the login is outdated and some other api links may be as well. Login should be this v1/clients/web/login.
这可能不是解决方案,但创建者有一个可以导入的邮递员集合,登录已过时,其他一些API链接可能也是如此。登录应为v1/客户端/Web/登录。
If you look at version 9 on the docs under Miscellaneous there is a nice postman collection for testing your api. I also found a nice package to generate new postman requests from your current api. For creating a current postman api I just imported the environment from version 9 docs. Then I added a variable called base_url it is same as the domain variable. After installing the package, I ran php artisan export:postman --bearer="your token" then just opened the generated file and copied and pasted the json into the Import function of Postman. Here is the package on github https://github.com/andreaselia/laravel-api-to-postman Cheers!
如果你看一下文档中的版本9,就会发现有一个很好的邮递员集合,可以用来测试你的API。我还发现了一个很好的包,可以从您当前的API生成新的邮递员请求。为了创建当前的邮递员API,我刚刚从版本9文档中导入了环境。然后我添加了一个名为base_url的变量,它与域变量相同。在安装该包之后,我运行php artisan EXPORT:postman--beeller=“Your Token”,然后打开生成的文件,将json复制并粘贴到Postman的导入函数中。这是GitHub https://github.com/andreaselia/laravel-api-to-postman干杯上的包裹!
Oh, I just realized you found the postman collection, but as I said some of it is outdated for version 11.
哦,我刚刚意识到你找到了邮递员的收藏,但正如我所说的,其中一些已经过时了,不适用于版本11。
One other thing to check. In postman the default Accept header was * / * I had to disable this header and add a new Accept application/json header
还有一件事需要检查。在邮递员中,默认的Accept标头是*/*我必须禁用此标头并添加新的Accept Application/json标头
One other thing, make sure this works, open your browser and goto http://api.apiato.test/v1 You should see a JSON response with message: "Welcome to apiato (API V1)." Also, if your server is using a port make sure you add that to your base_url or domain in post man. Example mine is
http://api.apiato.test:8000. Also make sure you update your host file according to the docs.
还有一件事,要确保它正常工作,打开浏览器并转到http://api.apiato.test/v1,您应该会看到一条JSON响应消息:“欢迎使用apiato(APIV1)。”此外,如果您的服务器使用端口,请确保将其添加到POST MAN中的base_url或域。我的例子是http://api.apiato.test:8000.还要确保您根据文档更新您的主机文件。
One more thing you need for postman to work with your new collection.
邮递员还需要一件事来处理你的新收藏。
Add this to your login under Tests.
将其添加到您的测试下的登录名中。
if (responseCode.code === 200) {
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("access_token", jsonData.access_token);
postman.setEnvironmentVariable("expires_in", jsonData.expires_in);
postman.setEnvironmentVariable("refresh_token", jsonData.refresh_token);
postman.setEnvironmentVariable("token_type", jsonData.token_type);
}
If(ResponseCode.code=200){var jsonData=JSON.parse(ResponseBody);postman.setEnvironmentVariable(“access_token”,jsonData.Access_Token);postman.setEnvironment变量(“Expires_in”,jsonData.expres_in);postman.setEnvironmentVariable(“refresh_token”,jsonData.renh_Token);postman.setEnvironment变量(“Token_type”,jsonData.Token_type);}
Add this to your logout under Tests.
将此内容添加到您在测试下的注销中。
if (responseCode.code === 202) {
postman.setEnvironmentVariable("access_token", "");
postman.setEnvironmentVariable("expires_in", "");
postman.setEnvironmentVariable("refresh_token", "");
postman.setEnvironmentVariable("token_type", "");
}
如果(responseCode.code = 202){ postman.setEnvironmentVariable(“access_token”,“”); postman.setEnvironmentVariable(“expires_in”,“”); postman.setEnvironmentVariable(“refresh_token”,“”); postman.setEnvironmentVariable(“token_type”,“”); }
Then click on your collection and under Authorization change type to Bearer token and set the Token to {{access_token}}
然后单击您的集合,并在授权下将类型更改为持有者令牌,并将令牌设置为{{Access_Token}}
更多回答
我是一名优秀的程序员,十分优秀!