我在将以下代码发送到POST / GET信息时遇到问题。
POST和GET都会产生403(禁止)错误。
使用Postman,请求发送正常并创建问题没有问题。
我错过了什么?我无法弄清楚Jira是否存在不允许请求的问题,或者我的auth标头在它到达Jira之前的某个地方被剥离了。
但是随着Postman的工作正常,它让我认为这与我的代码有关。
张贴申请:
var data = {
"fields": {
"project": {
"key": "test"
},
"summary": "test",
"description": "test",
"issuetype": {
"id": "3"
}
}
}
$.ajax({
url: "/rest/api/2/issue/",
method: "POST",
dataType: "JSON",
Authorization: "Basic eC1tZWdhbjpkYjUtN2ZVdDI2NjI=",
contentType: "application/json",
data : JSON.stringify(data)
}).done(function(response) {
console.log("awesome this works!");
console.log(response);
console.log(data);
}).fail(function(fail) {
console.log("nope, try again");
console.log(fail);
console.log(data);
});
});
获取请求
$.ajax({
type: "GET",
url: "/rest/api/2/issue/TEST-1",
dataType: "JSON",
Authorization: "Basic eC1tZWdhbjpkYjUtN2ZVdDI2NjI=",
error: function(error) {
console.log(error);
console.log(arguments);
},
success: function ()
{
alert('Thanks for your comment!');
}
});
答案 0 :(得分:0)
您需要将您的授权放在标题中:
Caused by: java.lang.IllegalStateException: Unable to load component interface org.sonar.scanner.scan.branch.BranchConfiguration
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:64)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
at org.picocontainer.injectors.SingleMemberInjector.getMemberArguments(SingleMemberInjector.java:61)
at org.picocontainer.injectors.MethodInjector.getMemberArguments(MethodInjector.java:100)
at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:112)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:62)
... 111 more
Caused by: java.lang.AbstractMethodError: com.sonarsource.branch.A.load(Ljava/util/Map;Ljava/util/function/Supplier;Lorg/sonar/scanner/scan/branch/ProjectBranches;Lorg/sonar/scanner/scan/branch/ProjectPullRequests;)Lorg/sonar/scanner/scan/branch/BranchConfiguration;
at org.sonar.scanner.scan.branch.BranchConfigurationProvider.provide(BranchConfigurationProvider.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129)
at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39)
at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:62)
希望这有帮助!