无论如何都要做与AddQueryOptions相同的事情但是在通过OData Web服务进行POST时?例如:
var first = ctx.JobGLJournal.AddQueryOptions("tenant", "fr").First();
POST网址也需要这个“租户”,但在执行SaveChanges时我找不到任何方法来添加它。如果我省略它,它将抛出服务器凭据错误。 此外,它无法与租户初始化DataServiceContext。
POST网址:
http://localhost:8058/OData/Company( 'XXX')/ JobGLJournal?租户= FR
答案 0 :(得分:0)
将其整理出来......需要添加一个BuildingRequest事件
i = (page-1)*ITEMS_PER_PAGE
entries = entries_sorted[i:i+5]
#entries_paginated = entries_sorted.paginate(page,ITEMS_PER_PAGE,False)
pagination = Pagination(page=page, total=len(entries_sorted),record_name='Feeds',per_page=ITEMS_PER_PAGE)
return render_template('index.html',title='Home Page',entries_sorted=entries,pagination=pagination)
并在Ctx_BuildingRequest中更改RequestUri
try {
...
Log.d(TAG, "code: " + conn.getReturnCode());
InputStream is = conn.getInputStream();
String serverReply = readIt(is, 500);
Log.d(TAG, serverReply);
...
}
public String readIt(InputStream stream, int len) throws IOException, UnsupportedEncodingException {
Reader reader = null;
reader = new InputStreamReader(stream, "UTF-8");
char[] buffer = new char[len];
reader.read(buffer);
return new String(buffer);
}