无法在Django中获取AngularJS的$ http.post数据(Cant get AngularJS's $http.post data in Django)
我知道这是一个非常基本的问题,但在浪费了我一整天后,我都在问这个问题。 我只是使用以下AngularJS代码向Django发送数据:
$http.post('/data/creation', { html: 'a' }). success(function(data, status, headers, config) { // this callback will be called asynchronously // when the response is available console.log(data); console.log(status); console.log(headers); console.log(config); }). error(function(data, status, headers, config) { // called asynchronously if an error occurs // or server returns response with an error status. console.log(status); console.log(data); });
在django:
@csrf_exempt def snippets_post(request): html = False css = False js = False JSONdata = False response = "You're looking at the results of question %s." if request.method == 'POST': try: JSONdata = request.POST.get('data', False) # it was [] in actual except: JSONdata = 'ERROR' return HttpResponse(JSONdata)
我得到False作为回应, “通过在POST中将数据替换为html。结果是相同的” 。 我不知道这里出了什么问题。 任何人都可以帮我这个吗?
谢谢
I know its a very basic question but after wasting my whole day I am asking this. I am just sending data using following AngularJS code to Django:
$http.post('/data/creation', { html: 'a' }). success(function(data, status, headers, config) { // this callback will be called asynchronously // when the response is available console.log(data); console.log(status); console.log(headers); console.log(config); }). error(function(data, status, headers, config) { // called asynchronously if an error occurs // or server returns response with an error status. console.log(status); console.log(data); });
and in django:
@csrf_exempt def snippets_post(request): html = False css = False js = False JSONdata = False response = "You're looking at the results of question %s." if request.method == 'POST': try: JSONdata = request.POST.get('data', False) # it was [] in actual except: JSONdata = 'ERROR' return HttpResponse(JSONdata)
I am getting False as response, "by replacing data to html in POST.get result is same". I don't know whats going wrong here. Can any one help me here on this?
Thanks
原文:https://stackoverflow.com/questions/26742922
最满意答案
在此问题得到解决之前,有两种方法可以解决此问题:
使用Azure AD PowerShell,您可以禁用然后删除应用程序角色。 这是一个可以实现此目的的示例脚本:
$appId = "83d7d56d-6e64-4791-b8e8-9a8da8dd957e" $appRoleValue = "app-role-value" # i.e. the scope Connect-AzureAD # Disable the AppRole $app = Get-AzureADApplication -Filter "appId eq '$appId'" ($app.AppRoles | Where-Object { $_.Value -eq $appRoleValue }).IsEnabled = $false Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $app.AppRoles # Remove the AppRole $toRemove = $app.AppRoles | Where-Object { $_.Value -eq $appRoleValue } $app.AppRoles.Remove($toRemove) | Out-Null Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $app.AppRoles
另一种选择是使用Azure AD Graph Explorer并在Application对象上发出两个
PATCH
请求。 第一个PATCH
请求应将app角色的isEnabled
属性设置为false
。 然后,第二个PATCH
请求可以删除app角色(即包括除已禁用的角色之外的所有现有app角色)。Until this gets fixed, there two options to work around this issue:
Using Azure AD PowerShell, you can disable and then remove the app role. Here's a sample script that would achieve this:
$appId = "83d7d56d-6e64-4791-b8e8-9a8da8dd957e" $appRoleValue = "app-role-value" # i.e. the scope Connect-AzureAD # Disable the AppRole $app = Get-AzureADApplication -Filter "appId eq '$appId'" ($app.AppRoles | Where-Object { $_.Value -eq $appRoleValue }).IsEnabled = $false Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $app.AppRoles # Remove the AppRole $toRemove = $app.AppRoles | Where-Object { $_.Value -eq $appRoleValue } $app.AppRoles.Remove($toRemove) | Out-Null Set-AzureADApplication -ObjectId $app.ObjectId -AppRoles $app.AppRoles
An alternative option is to user the Azure AD Graph Explorer and issue two
PATCH
requests on the Application object. The firstPATCH
request should set the app role'sisEnabled
attribute tofalse
. The secondPATCH
request can then remove the app role (i.e. include all existing app roles except the disabled one).
相关问答
更多-
没有! Windows Azure Active Directory不是域控制器。 您不能将计算机加入Windows Azure AD。 您可以使用它将本地AD与Windows Azure AD同步,以轻松启用Web SSO(单一登录)。 您可以使用它来构建企业级Web应用程序。 您可以在这里阅读有关Windows Azure Active Directory的更多信息。 NO! Windows Azure Active Directory is NOT a Domain Controller. You c ...
-
在Azure Active Directory中删除应用程序的AppRole(Deleting an Application's AppRole in Azure Active Directory)[2023-06-03]
在此问题得到解决之前,有两种方法可以解决此问题: 使用Azure AD PowerShell,您可以禁用然后删除应用程序角色。 这是一个可以实现此目的的示例脚本: $appId = "83d7d56d-6e64-4791-b8e8-9a8da8dd957e" $appRoleValue = "app-role-value" # i.e. the scope Connect-AzureAD # Disable the AppRole $app = Get-AzureADApplication -Filte ... -
不,使用Azure AD提供的功能无法连接互联网是不可能的。 可以在VirtualBox中创建一个本地虚拟机,并包含所有必需的AD功能,然后切换软件以在开发模式下使用本地虚拟机,但在发布模式下使用Azure AD? 如果要使用身份验证,则在脱机工作时可能需要设置自己的身份提供程序服务器。 有许多开源库可以帮助设置身份提供商服务器,如IndentyServer , AspNet.Security.OpenIdConnect.Server等。 No, it is impossible to use the fe ...
-
在Azure Active Directory中,用户同意被注册为用户对象和表示客户端应用程序的服务主体对象之间的链接。 此链接在AAD Graph API中表示为OAuth2PermissionGrant 你说的这个: 现在,该用户所做的是从Azure AD手动删除我们的应用程序(再次通过“应用程序”选项卡)。 根据我们对同意模型的理解,这意味着用户已取消对我们的申请的同意。 我想澄清一下。 您可能知道,在创建新的AAD应用程序时,需要记住应用程序对象和服务主体之间的区别。 具体而言,如果您删除代表客户端 ...
-
你的问题很广泛,由几个问题组成,因此很难简明扼要地回答。 如果您的用户已经在您的Azure AD中,则应该将其用作用户存储。 但是,如果它们不在您的组织之中,则可以使用Azure AD B2C,其中包含用于创建自助式帐户的功能。 或者查看https://stackoverflow.com/a/16068340 ,了解如何为公共用户使用AAD的建议。 如果用户已经存在于您的AAD中,并且您尚未在AAD中的应用程序上设置用户分配,则他们可以登录到应用程序。 如果您对此有兴趣,您可以使用基于角色的安全性为用户授予 ...
-
我终于找到了答案。 为了从ServicePrincipal获取AppRoleAssignments,您需要直接查询列表,而不是尝试将其从ServicePrincipal扩展: await client.ServicePrincipals .GetByObjectId(servicePrincipalObjectId) .AppRoleAssignedTo .ExecuteAsync() 然后,您必须手动浏览用户和组以获取最终用户列表。 这可能会导致许多Graph API服务调用,具 ...
-
Azure Active Directory不支持LDAP协议,因此您将无法使用.NET的System.DirectoryService类。 AAD服务使用称为Graph API的东西来查询目录数据。 这是一个基于REST的Web API。 http://msdn.microsoft.com/en-us/library/windowsazure/hh974476.aspx 如果要通过AAD进行身份验证,可以使用ADAL库: http://msdn.microsoft.com/en-us/library/wi ...
-
2016年9月更新 :现在可以从新门户中选择无限到期日期。 在幕后,它实际上并不是无限的,但它确定了未来很远的日期。 来源: https : //stephaneeyskens.wordpress.com/2016/01/14/managing-expiration-of-azure-active-directory-application-client-secrets/ Update September 2016: it is now possible to chose an infinite expir ...
-
我理解这一点的方式是Azure AD(用户管理,计费管理等)中的角色仅适用于Azure AD。 它们与订阅角色(您在Azure门户中设置的角色,如所有者,贡献者,读者)无关。 您需要做的是在旧门户中的Azure AD中创建这些用户后,返回Azure门户并根据您的要求为这些用户分配订阅角色。 一旦这些人员分配了订阅角色,他们就应该能够访问Azure门户。 您可能会发现此链接对分配订阅角色很有用: https : //azure.microsoft.com/en-in/documentation/article ...
-
Azure Active Directory是一种多租户服务,可为云应用程序提供身份和访问管理。 它与Server Active Directory不同,也不是在Azure中的虚拟机中运行的Windows Server AD实例。 所以,回答你的问题 - 没有。 如果您希望服务器AD的实例测试LDAP查询,则可以在虚拟机中旋转一个。 您需要将其放入虚拟网络中。 此外,创建虚拟机的实例以在要测试的应用程序上运行应用程序。 本教程应该为您解决。 http://www.windowsazure.com/en-us ...