Short Description:

This article will describe on how to disable CSRF protection in Ambari.

Article

Adding service through ambari gives error as shown below -

[root@sandbox ~]# curl -u admin:admin -i -X POST -d '{"ServiceInfo":{"service_name":"STORM"}}' http://192.168.123.129:8080/api/v1/clusters/Sandbox/services
HTTP/1.1 400 Bad Request
Set-Cookie: AMBARISESSIONID=qraouzksi4vktobhob5heqml;Path=/
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Content-Length: 107
Server: Jetty(7.6.7.v20120910)
{
"status" : 400,
"message" : "CSRF protection is turned on. X-Requested-By HTTP header is required."

You need to disable CSRF protection as mentioned below -

1.Login to ambari server using cli [superuser credentials]

vi /etc/ambari-server/conf/ambari.properties

2. Add below line at the bottom of the file

api.csrfPrevention.enabled=false

3. Restart ambari server

ambari-server restart

4. Try executing POST command again to add service and it should work

[root@sandbox ~]# curl -u admin:admin -i -X POST -d '{"ServiceInfo":{"service_name":"STORM"}}' http://192.168.123.129:8080/api/v1/clusters/Sandbox/services
HTTP/1.1 201 Created
Set-Cookie: AMBARISESSIONID=1t4c7yfbu64nw1nenrgplco7sd;Path=/
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/plain
Content-Length: 0
Server: Jetty(7.6.7.v20120910)

Thanks.

How to resolve CSRF protection error while adding service through Ambari api的更多相关文章

  1. Creating a CSRF protection with Spring 3.x--reference

    reference from:http://info.michael-simons.eu/2012/01/11/creating-a-csrf-protection-with-spring-3-1/ ...

  2. "cni0" already has an IP address different from 10.244.2.1/24。 Error while adding to cni network: failed to allocate for range 0: no IP addresses available in range set: 10.244.2.1-10.244.2.254

    "cni0" already has an IP address different from 10.244.2.1/24. Error while adding to cni n ...

  3. How do I resolve the CodeSign error: CSSMERR_TP_NOT_TRUSTED?

    How do I resolve the CodeSign error: CSSMERR_TP_NOT_TRUSTED? The Xcode build error titled "CSSM ...

  4. HTML form without CSRF protection,HTML表单没有CSRF保护

    HTML form without CSRF protection =HTML表单没有CSRF保护 CSRF是伪造客户端请求的一种攻击,CSRF的英文全称是Cross Site Request For ...

  5. E-Business Suite 12.2 startCD 50 Install Fails with Fatal Error: TXK Install Service oracle.apps.fnd.txk.config.ProcessStateException: OUI process failed Cannot install Web Tier Utilities

    在rhel7.2上,使用startCD 50安装ebs r12.2的使用,安装到38%的时候就报错,遇到了和以下文章类似的问题: http://www.cnblogs.com/abclife/p/49 ...

  6. WIN7 + IIS7 Service Unavailable HTTP Error 503. The service is unavailable.

    在win7上开启IIS功能,进行网站发布. 但是开启IIS之后,打开默认网站都打不开,显示 Service Unavailable HTTP Error 503. The service is una ...

  7. adb shell出错“error: unknown host service”

    已经测试,可用: 在命令行输入adb shell后输出如下错误: adb server is out of date.  killing... ADB server didn't ACK * fail ...

  8. HTTP Error 503. The service is unavailable

    网站运行一段时间后,突然所有的页面都报告以下错误: HTTP Error 503. The service is unavailable 经检查,应用程序池自动停止,可能是工作进程抛出的异常数超出限制 ...

  9. Adding Swagger to Web API project

    Adding Swagger to Web API project. All source code for this series can be found here. When you creat ...

随机推荐

  1. OpenStack架构详解

    OpenStack提供开放源码软件,建立公共和私有云. OpenStack是一个社区和一个项目,以及开放源码软件,以帮助企业运行的虚拟计算或者存储云. OpenStackd开源项目由社区维护,包括Op ...

  2. Tiny4412之重力感应器驱动

    一:Tiny4412 裸板重力感应驱动编写 整个编写过程大概分为如下几步: (1)在底板上找到重力感应器的所在位置,找到芯片型号(我用的板子上重力感应器芯片型号为:MMA7660FC) (2)通过型号 ...

  3. SSM-MyBatis-10:Mybatis中SqlSession的getMapper()和简单的工具类MyBatisUtils

    ------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- getMapper的作用,获取到接口,直接通过点的方式调用方法,以免直接手打的方式写错方法名,(强类型的方式) ...

  4. WireShark基本抓包数据分析

    WireShark抓包数据分析: 1.TCP报文格式 •  源端口.目的端口:16位长.标识出远端和本地的端口号. •  顺序号:32位长.表明了发送的数据报的顺序. •  确认号:32位长.希望收到 ...

  5. 聊一聊顺序消息(RocketMQ顺序消息的实现机制)

    当我们说顺序时,我们在说什么? 日常思维中,顺序大部分情况会和时间关联起来,即时间的先后表示事件的顺序关系. 比如事件A发生在下午3点一刻,而事件B发生在下午4点,那么我们认为事件A发生在事件B之前, ...

  6. Python3 venv 创建虚拟环境

    简介 Python3.3以上的版本通过venv模块原生支持虚拟环境,可以代替Python之前的virtualenv. 该venv模块提供了创建轻量级"虚拟环境",提供与系统Pyth ...

  7. Ubuntu配置SecureCRT登录

    1. 命令行切换到root用户 备注:ubuntu默认root用户没有设置密码,切换需要首先设置密码 sudo passwd root 按照提示输入当前用户密码 按照提示输入要设置的root用户密码 ...

  8. python高级编程1

    1.如何在列表,字典,集合中根据条件筛选数据? 如: 过滤列表[3, 9, -1, 10, 20, -2...]中的负数 筛出字典{‘小明’:70, 'Jim':88,'Tom':98...}中值高于 ...

  9. Oracle 启动监听命令

    win10系统,在win右击"运行"-->输入"services.msc" ,来到服务窗口,找Oracle的相关服务 OracleOraDb10g_hom ...

  10. BZOJ_2809_[Apio2012]dispatching_可并堆

    BZOJ_2809_[Apio2012]dispatching_可并堆 Description 在一个忍者的帮派里,一些忍者们被选中派遣给顾客,然后依据自己的工作获取报偿.在这个帮派里,有一名忍者被称 ...