我正在尝试使用下面的 REST API 调用 REST API 来获取列表
https://myweb.sharepoint.com/teams/sites/subwebs/_api/web/lists/GetByTitle('MyList')/Items?
$top=1
&$orderby=ID
&$select=ID,FName,LName,Title
&$filter=Title eq 'Female'
Run Code Online (Sandbox Code Playgroud)
我需要 $filter 应该与限制为 $top 的记录数量一起工作。如果未应用 $filter,则 $top 起作用。
好吧,我的列表包含超过 5000 个项目。我在对上述 URL 发出 GET 请求时收到以下错误消息
{
"readyState": 4,
"responseText": "{\"odata.error\":{\"code\":\"-2147024860, Microsoft.SharePoint.SPQueryThrottledException\",\"message\":{\"lang\":\"en-US\",\"value\":\"The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.\"}}}",
"responseJSON": {
"odata.error": {
"code": "-2147024860, Microsoft.SharePoint.SPQueryThrottledException",
"message": {
"lang": "en-US",
"value": "The attempted operation is prohibited because it exceeds the list view threshold enforced by the `enter code here`administrator." …Run Code Online (Sandbox Code Playgroud) 我正在创建一个 RESTful API 并遵循它的最佳实践,但我对此产生了很大的怀疑。
我需要创建一个报告(带有图表和数据表),它由分析其他资源(评估)组成,并且许多其他参数使得该报告在显示的数据上是可变的。
因此,在寻找最佳实践时,我不知道是否需要获取所有数据,并在 Javascript 中对其进行处理,以制作报告(客户端),因此 RESTful 模式不是问题;
或者我如何命名由许多其他资源组成的资源“报告”。我不安的心想创建一个/api/rest/reports/executiveReport?evaluation=:id&competences=:id&competences=:id&employee=:iduri
我怎样才能在一个漂亮的 RESTful 模式 uri 中实现这一点?我不想在 Javascript 中处理数据,因为有很多错误或我无法捕获的异常。我更喜欢提交要显示的报告。
谢谢!
所以我的目标是使用 ISO Alpha-2 国家/地区代码找到一个国家/地区的名称。我认为这是第一次尝试 RESTful API(确切地说是世界银行 API )的好时机。我开始使用本教程来尝试实现我的目标,它似乎requests.get()是我问题的答案,我尝试了一下并得到了这个:
(InteractiveConsole)
>>> import requests
>>> resp = requests.get('http://api.worldbank.org/countries/br')
>>> resp
<Response [200]>
>>> resp.json()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\site-packages\requests\models.py", line 866, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\username\AppData\Local\Programs\Python\Python35\lib\json\__init__.py", line 315, in loads
s, 0)
json.decoder.JSONDecodeError: Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)
Run Code Online (Sandbox Code Playgroud)
我不太确定出了什么问题或者它告诉我要做什么(我对 JSON 不太熟悉)。对此有什么解释以及如何解决它吗?
我在用:
Windows 7 64 位
Python 3.5.1
姜戈 …
我们可以使用 python 的单个 GET 请求从 REST 服务器获取连续数据吗?我暂时使用烧瓶。
@app.route('/', methods = ['GET'])
def hello_world():
while True:
return 'Hello World!'
Run Code Online (Sandbox Code Playgroud)
这将返回“Hello World!” 一次,但我希望将字符串连续发送到客户端,直到服务器程序停止或按下硬件停止(CTRL + C)。或者甚至我很乐意在给定时间内连续发送字符串或 XML。
我创建了 api 结构/配置并且它可以工作,但现在我需要使用承载身份验证对其进行设置,并且我发送到 api 的每个 GET 请求(使用身份验证承载 XXXXXXXXXXXX)都会给我一个 401 错误:
{"name":"Unauthorized","message":"Your request was made with invalid credentials.","code":0,"status":401,"type":"yii\\web\\UnauthorizedHttpException"}
Run Code Online (Sandbox Code Playgroud)
对于这个问题的长度以及所有片段感到抱歉,但我尝试了一些更改,阅读了我在这里找到的所有内容,但没有成功,我开始对此失去控制。我可能会错过什么?
我的应用程序使用具有下一个文件夹结构的高级模板(与我读过的所有方法相同):
> -api
> --config
> --main.php
> --params.php
> --modules
> --v1
> --controllers
> --OrdersController.php
> --models
> --Orders.php
> --Module.php
> --web
> --index.php
> -backend
> -common
> -frontend...
Run Code Online (Sandbox Code Playgroud)
api/config/main.php
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php')
//require(__DIR__ . '/params-local.php')
);
return [
'id' => 'app-api',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'], …Run Code Online (Sandbox Code Playgroud) 我从 url 获取以下 json:
{"bytes": 5043, "name": "a", "timestamp": "11-Apr-2017 12:11:51", "ds": "Lab1"}
{"bytes": 0, "name": "b", "timestamp": "11-Apr-2017 12:11:51", "ds": "Lab1"}
{"bytes": 11590, "name": "c", "timestamp": "11-Apr-2017 12:11:51", "ds": "Lab1"}
Run Code Online (Sandbox Code Playgroud)
我想返回每行的字节。使用 Jackson 我尝试按如下方式解析它(注意:json 保存到文件中以进行测试):
package JsonRead;
import java.io.File;
import java.io.IOException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JacksonTreeModelLogStorage {
public static void main(String[] args) {
try{
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(new File("JsonRead/json2.json"));
JsonNode logStorageNode = root;
for(JsonNode node : logStorageNode){
String bytesUsed = node.path("bytes").asText();
System.out.println("Bytes Used: …Run Code Online (Sandbox Code Playgroud) 大家好,我在为我的应用程序设置安全解决方案时遇到问题!因此,我有一个在http://localhost:51030运行并使用 Spring Framework 开发的 REST API 后端,而在前端,我有一个在http://localhost运行的 Angular 2 应用程序(最新版本又称为 Angular 4) :4200。我在后端设置了 CORS 配置,如下所示:
public class CORSFilter implements Filter
{
// The list of domains allowed to access the server
private final List<String> allowedOrigins = Arrays.asList("http://localhost:4200", "http://127.0.0.1:4200");
public void destroy()
{
}
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException
{
// Lets make sure that we are working with HTTP (that is, against HttpServletRequest and HttpServletResponse objects)
if (req instanceof HttpServletRequest …Run Code Online (Sandbox Code Playgroud) 我正在尝试:
按照Microsoft Graph Explorer上的Update taskDetails文档,我正在尝试对以下内容发出 PATCH 请求:
https://graph.microsoft.com/beta/tasks/{Id}/details
Run Code Online (Sandbox Code Playgroud)
请求头:
Content-type: application/json
Prefer: "return=represent"
If-Match: {@odata.etag from a successful prior GET on taskDetails}
Run Code Online (Sandbox Code Playgroud)
请求正文:
{
"description": "My new description",
"previewType": "description",
"references": {},
"checklist": {}
}
Run Code Online (Sandbox Code Playgroud)
回复:
client-request-id: {some Id}
content-type: application/json
cache-control: private
request-id: {some Id}
Status Code: 412 <--- Pre-condition not met!
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "{some Id}",
"date": "{date}"
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用 Chrome 开发者工具解析响应头:
HTTP/1.1 412 …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我根据这些问题开发的 REST API 创建一个过滤器Best Practice for REST token-based authentication with JAX-RS and Jersey。
问题是我调用过滤器的任何方法似乎都不起作用。
这些是我的课程:
安全.java
@NameBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Secured {
}
Run Code Online (Sandbox Code Playgroud)
验证过滤器.java
@Secured
@Provider
@Priority(Priorities.AUTHENTICATION)
public class AuthenticationFilter implements ContainerRequestFilter{
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
// Get the HTTP Authorization header from the request
String authorizationHeader =
requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
// Check if the HTTP Authorization header is present and formatted correctly
if (authorizationHeader == null || !authorizationHeader.startsWith("Bearer ")) {
throw new NotAuthorizedException("Authorization …Run Code Online (Sandbox Code Playgroud) 我使用以下 JSON RESTlet 脚本来导出一些数据。由于限制,它的上限为 1000 行,这远低于我需要导出的总数。我遇到过一些不同的解决方案,但 JSON/RESTlet 对我来说相当新,因此我正在寻找一些关于如何调整代码以循环所有结果的反馈。
function GetSearchResult(){
//array container for search results
var output = new Array();
//get search results
var results = nlapiSearchRecord('transaction','customsearchid',null,null);
var columns = results[0].getAllColumns();
//loop through the search results
for(var i in results){
//create placeholder object place holder
var obj = new searchRow(
//set the values of the object with the values of the appropriate columns
results[i].getValue(columns[0]),
results[i].getValue(columns[1]),
results[i].getValue(columns[2]),
results[i].getValue(columns[3]),
results[i].getValue(columns[4]),
results[i].getValue(columns[5]),
results[i].getValue(columns[6]),
results[i].getValue(columns[7]),
results[i].getValue(columns[8]),
results[i].getValue(columns[9]),
results[i].getValue(columns[10]),
results[i].getValue(columns[11]),
results[i].getValue(columns[12])
);
//add the object …Run Code Online (Sandbox Code Playgroud)