I'm trying to do a HTTP operation with PATCH method toward a Groovy Script. If I do that request with Postman Interface I obtain a 200 ok but when I do with the Groovy Script I obtain a 405 Error Code.
Postman Request:
Postman Request
That request is did for a Groovy with JSON Data.
The function that process the request is the next:
public Object sendHttpRequest(String url, String operation, String jsdonData,
String user, String password) throws Exception {
println("Start sendHttpRequest() method");
Object gesdenResponse = null;
HttpURLConnection conn = null;
try {
println("Opening HTTP connection...");
println("URL: " + url);
URL obj = new URL(url);
conn = (HttpURLConnection) obj.openConnection();
conn.setRequestProperty("Authorization", String.format("Basic %s", getProtectedCredentials(user, password)));
println("Header \"Authorization: *****\" set up");
String method = null;
switch (operation) {
case "PASSWORD":
method = 'PATCH';
println("PASSWORD Operation");
break;
default:
break;
}
if (method?.equals("PUT") || method?.equals("POST") ||method?.equals("PATCH")) (conn.setDoOutput(true));
if (method == "PATCH") {
println("MODIFICAMOS CABECERA PARA PATCH ");
conn.setRequestProperty("X-HTTP-Method-Override", "PATCH");
conn.setRequestMethod("POST");
} else {
conn.setRequestMethod(method);
}
println("Setting up custom HTTP headers...");
conn.setRequestProperty(GesdenConstants.HTTP_CUSTOM_HEADER_SYSTEM_KEY, GesdenConstants.HTTP_CUSTOM_HEADER_SYSTEM_VALUE);
println(String.format("Custom header \"%s: %s\" set up", GesdenConstants.HTTP_CUSTOM_HEADER_SYSTEM_KEY, GesdenConstants.HTTP_CUSTOM_HEADER_SYSTEM_VALUE));
conn.setRequestProperty(GesdenConstants.HTTP_CUSTOM_HEADER_ACCEPT_KEY, GesdenConstants.HTTP_CUSTOM_HEADER_ACCEPT_VALUE);
println(String.format("Custom header \"%s: %s\" set up", GesdenConstants.HTTP_CUSTOM_HEADER_ACCEPT_KEY, GesdenConstants.HTTP_CUSTOM_HEADER_ACCEPT_VALUE));
conn.setRequestProperty(GesdenConstants.HTTP_CUSTOM_HEADER_CONTENT_TYPE_KEY, GesdenConstants.HTTP_CUSTOM_HEADER_CONTENT_TYPE_VALUE);
println(String.format("Custom header \"%s: %s\" set up", GesdenConstants.HTTP_CUSTOM_HEADER_CONTENT_TYPE_KEY, GesdenConstants.HTTP_CUSTOM_HEADER_CONTENT_TYPE_VALUE));
if (jsdonData != null && !jsdonData.isEmpty()) {
conn.setRequestProperty("Content-Length", String.format("%s", Integer.toString(jsdonData.getBytes().length)));
conn.getOutputStream().write(jsdonData.getBytes("UTF-8"));
println(String.format("JSON data set up" + conn));
}
println("Waiting for server response...");
println(String.format("conn es "+conn));
BufferedReader input = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String inputLine;
StringBuffer data = new StringBuffer();
println(String.format("linea " +inputLine));
while ((inputLine = input.readLine()) != null)
{
data.append(inputLine);
println(String.format("linea " +inputLine));
}
} catch (Exception e) {
throw e;
} finally {
if (conn != null) {
conn.disconnect();
println("HTTP connection closed");
}
println("Finish sendHttpRequest() method");
}
return gesdenResponse;
}
The log of the code is the next:
2019-08-30 10:18:07.981 INFO 22051 --- [ container-1] c.g.gesden.ResetPasswordScriptConnector : ***** SET PASSWORD started ******
2019-08-30 10:18:08.579 INFO 22051 --- [ container-1] c.g.gesden.ResetPasswordScriptConnector : Show me the url: http://10.4.8.107:8080/ServiceGesdenScim-1.0/Users/popen070/password
2019-08-30 10:18:08.586 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Start toJSON() method
2019-08-30 10:18:08.589 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Finish toJSON() method
2019-08-30 10:18:08.589 INFO 22051 --- [ container-1] c.g.gesden.ResetPasswordScriptConnector : El cuerpo del JSON es: {"password":"Pabloarevalo11"}
2019-08-30 10:18:08.589 INFO 22051 --- [ container-1] c.g.gesden.ResetPasswordScriptConnector : ***** SET PASSWORD antes del response ******
2019-08-30 10:18:08.592 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Start sendHttpRequest() method
2019-08-30 10:18:08.592 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Opening HTTP connection...
2019-08-30 10:18:08.592 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : URL: http://10.4.8.107:8080/ServiceGesdenScim-1.0/Users/popen070/password
2019-08-30 10:18:08.594 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Header "Authorization: *****" set up
2019-08-30 10:18:08.594 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : PASSWORD Operation
2019-08-30 10:18:08.594 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Method: PATCH
2019-08-30 10:18:08.595 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : MODIFICAMOS LAS CABECERAS PARA PATCH
2019-08-30 10:18:08.595 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Setting up custom HTTP headers...
2019-08-30 10:18:08.595 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Custom header "Sistema: Sanitas" set up
2019-08-30 10:18:08.595 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Custom header "Accept: application/json" set up
2019-08-30 10:18:08.595 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Custom header "Content-Type: application/json" set up
2019-08-30 10:18:08.596 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : JSON data set upsun.net.www.protocol.http.HttpURLConnection:http://10.4.8.107:8080/ServiceGesdenScim-1.0/Users/popen070/password
2019-08-30 10:18:08.596 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Waiting for server response...
2019-08-30 10:18:08.596 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : conn es sun.net.www.protocol.http.HttpURLConnection:http://10.4.8.107:8080/ServiceGesdenScim-1.0/Users/popen070/password
2019-08-30 10:18:08.598 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Ha llegado Server returned HTTP response code: 405 for URL: http://10.4.8.107:8080/ServiceGesdenScim-1.0/Users/popen070/password
2019-08-30 10:18:08.598 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : HTTP connection closed
2019-08-30 10:18:08.598 INFO 22051 --- [ container-1] c.groovy.gesden.common.ConnectorUtils : Finish sendHttpRequest() method
2019-08-30 10:18:08.598 INFO 22051 --- [ container-1] c.g.gesden.ResetPasswordScriptConnector : An exception ocurred while setting the password for user popen070: Server returned HTTP response code: 405 for URL: http://10.4.8.107:8080/ServiceGesdenScim-1.0/Users/popen070/password
2019-08-30 10:18:08.598 INFO 22051 --- [ container-1] c.g.gesden.ResetPasswordScriptConnector : ****** SET PASSWORD finished ******
Related
I'm trying to make an http request to Github Api in Grails Controller.
I just started learning Grails yesterday and I'm stuck. I searched over internet for hours but it seems there is very little discussion about Grails on internet.
I simply want to call the Github Api and get user Data. I am familiar with the Api Endpoint, I have used it with other frameworks. But I am unable to figure out this (maybe) tiny problem in Grails.
Can anybody help me how do we make API calls in Grails controller?
Thanks in advance and Apologies for a naïve question.
Unable to Get Data from Github Api in Grails App
See the project at github.com/jeffbrown/tauseefahmedgithubapi.
src/main/groovy/tauseefahmedgithubapi/GitHubClient.groovy
package tauseefahmedgithubapi
import io.micronaut.http.annotation.Get
import io.micronaut.http.annotation.Header
import io.micronaut.http.client.annotation.Client
import static io.micronaut.http.HttpHeaders.USER_AGENT
#Client('https://api.github.com/')
interface GitHubClient {
#Get('/orgs/{org}/repos')
#Header(name = USER_AGENT, value = 'Micronaut Demo Application')
List<GitHubRepository> listRepositoriesForOrginazation(String org)
}
src/main/groovy/tauseefahmedgithubapi/GitHubRepository.groovy
package tauseefahmedgithubapi
import io.micronaut.core.annotation.Introspected
#Introspected
class GitHubRepository {
String name
}
grails-app/init/tauseefahmedgithubapi/BootStrap.groovy
package tauseefahmedgithubapi
import org.springframework.beans.factory.annotation.Autowired
class BootStrap {
#Autowired
GitHubClient client
def init = { servletContext ->
def repos = client.listRepositoriesForOrginazation('micronaut-projects')
for(def repo : repos) {
log.info "Repo Name: ${repo.name}"
}
}
def destroy = {
}
}
At application startup you may see output like this:
2021-06-28 13:03:16.834 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: static-website
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: presentations
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-core
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-profiles
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-guides-old
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-examples
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: static-website-test
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-docs
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-test
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-kotlin
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-spring
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-oauth2
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-liquibase
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-flyway
2021-06-28 13:03:16.836 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-elasticsearch
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-graphql
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-grpc
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-kafka
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-netflix
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-groovy
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-micrometer
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-sql
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-mongodb
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-redis
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-neo4j
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-rabbitmq
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-aws
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-rss
2021-06-28 13:03:16.837 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-gcp
2021-06-28 13:03:16.838 INFO --- [ restartedMain] tauseefahmedgithubapi.BootStrap : Repo Name: micronaut-kubernetes
I am using atlassian swagger request validator in my springboot application. I tried to configure all the beans as explained in the [official documentation][1]
[1]: https://bitbucket.org/atlassian/swagger-request-validator/src/master/swagger-request-validator-springmvc/. But I am getting the below error
{
"status": 400,
"error": "Bad Request",
"message": "{\r\n \"messages\" : [ {\r\n \"key\" : \"validation.request.body.schema.unknownError\",\r\n \"level\" : \"ERROR\",\r\n \"message\" : \"An error occurred during schema validation - null.\",\r\n \"context\" : {\r\n \"requestPath\" : \"/mybook/mypage/12345/rules/\",\r\n \"apiRequestContentType\" : \"application/json\",\r\n \"location\" : \"REQUEST\",\r\n \"requestMethod\" : \"POST\"\r\n }\r\n } ]\r\n}",
"trace": "com.atlassian.oai.validator.springmvc.InvalidRequestException: {\r\n \"messages\" : [ {\r\n \"key\" : \"validation.request.body.schema.unknownError\",\r\n \"level\" : \"ERROR\",\r\n \"message\" : \"An error occurred during schema validation - null.\",\r\n \"context\" : {\r\n \"requestPath\" : \"/mybook/mypage/12345/rules/\",\r\n \"apiRequestContentType\" : \"application/json\",\r\n \"location\" : \"REQUEST\",\r\n \"requestMethod\" : \"POST\"\r\n }\r\n } ]\r\n}\r\n\tat com.atlassian.oai.validator.springmvc.DefaultValidationReportHandler.createValidationException(DefaultValidationReportHandler.java:96)\r\n\tat com.atlassian.oai.validator.springmvc.DefaultValidationReportHandler.processApiValidationReport(DefaultValidationReportHandler.java:63)\r\n\tat com.atlassian.oai.validator.springmvc.DefaultValidationReportHandler.handleRequestReport(DefaultValidationReportHandler.java:49)\r\n\tat com.atlassian.oai.validator.springmvc.OpenApiValidationInterceptor.preHandle(OpenApiValidationInterceptor.java:96)\r\n\tat org.springframework.web.servlet.HandlerExecutionChain.applyPreHandle(HandlerExecutionChain.java:136)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1033)\r\n\tat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)\r\n\tat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)\r\n\tat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)\r\n\tat javax.servlet.http.HttpServlet.service(HttpServlet.java:660)\r\n\tat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)\r\n\tat
Any pointers to resolve this issue will be helpful
I believe the issue is with the latest version. I used 2.7x and is working fine
I have implemented the project as per https://spring.io/guides/gs/batch-processing/
But i am getting :
Error creating bean with name 'batchConfigurer': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
I am new to spring-batch
Can anyone please help
The following is working as expected:
$>git clone https://github.com/spring-guides/gs-batch-processing.git
$>cd gs-batch-processing/complete
$>./mvnw clean install
$>./mvnw spring-boot:run
The output is the following:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-05-30 12:23:12.642 INFO 90644 --- [ main] hello.Application : Starting Application on localhost with PID 90644 (/private/tmp/gs-batch-processing/complete/target/classes started by mbenhassine in /private/tmp/gs-batch-processing/complete)
2019-05-30 12:23:12.646 INFO 90644 --- [ main] hello.Application : No active profile set, falling back to default profiles: default
2019-05-30 12:23:13.333 INFO 90644 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-05-30 12:23:13.338 WARN 90644 --- [ main] com.zaxxer.hikari.util.DriverDataSource : Registered driver with driverClassName=org.hsqldb.jdbcDriver was not found, trying direct instantiation.
2019-05-30 12:23:13.683 INFO 90644 --- [ main] com.zaxxer.hikari.pool.PoolBase : HikariPool-1 - Driver does not support get/set network timeout for connections. (feature not supported)
2019-05-30 12:23:13.687 INFO 90644 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-05-30 12:23:14.091 INFO 90644 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: HSQL
2019-05-30 12:23:14.277 INFO 90644 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor.
2019-05-30 12:23:14.437 INFO 90644 --- [ main] hello.Application : Started Application in 2.114 seconds (JVM running for 5.2)
2019-05-30 12:23:14.438 INFO 90644 --- [ main] o.s.b.a.b.JobLauncherCommandLineRunner : Running default command line with: []
2019-05-30 12:23:14.503 INFO 90644 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=importUserJob]] launched with the following parameters: [{run.id=1}]
2019-05-30 12:23:14.530 INFO 90644 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [step1]
2019-05-30 12:23:14.590 INFO 90644 --- [ main] hello.PersonItemProcessor : Converting (firstName: Jill, lastName: Doe) into (firstName: JILL, lastName: DOE)
2019-05-30 12:23:14.590 INFO 90644 --- [ main] hello.PersonItemProcessor : Converting (firstName: Joe, lastName: Doe) into (firstName: JOE, lastName: DOE)
2019-05-30 12:23:14.590 INFO 90644 --- [ main] hello.PersonItemProcessor : Converting (firstName: Justin, lastName: Doe) into (firstName: JUSTIN, lastName: DOE)
2019-05-30 12:23:14.590 INFO 90644 --- [ main] hello.PersonItemProcessor : Converting (firstName: Jane, lastName: Doe) into (firstName: JANE, lastName: DOE)
2019-05-30 12:23:14.590 INFO 90644 --- [ main] hello.PersonItemProcessor : Converting (firstName: John, lastName: Doe) into (firstName: JOHN, lastName: DOE)
2019-05-30 12:23:14.604 INFO 90644 --- [ main] hello.JobCompletionNotificationListener : !!! JOB FINISHED! Time to verify the results
2019-05-30 12:23:14.607 INFO 90644 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JILL, lastName: DOE> in the database.
2019-05-30 12:23:14.607 INFO 90644 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JOE, lastName: DOE> in the database.
2019-05-30 12:23:14.607 INFO 90644 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JUSTIN, lastName: DOE> in the database.
2019-05-30 12:23:14.607 INFO 90644 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JANE, lastName: DOE> in the database.
2019-05-30 12:23:14.607 INFO 90644 --- [ main] hello.JobCompletionNotificationListener : Found <firstName: JOHN, lastName: DOE> in the database.
2019-05-30 12:23:14.610 INFO 90644 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=importUserJob]] completed with the following parameters: [{run.id=1}] and the following status: [COMPLETED]
As you can see, there is no NoClassDefFoundError.
2 jars were corrupted , jackson-data bind and log4 .
While mvn clean install error was (invalid LOC header bad signature) in the logs but build was getting successfull hence i missed the logs.
i had to delete the folder from .m2 and then run mvn clean install this resolved the issue
I found some thread the same problem but their answers not works for me.
I have a post request to check user login.
Url form :
"http://support.xxx.xx:8031/serpapi/login/checkLogin"
Parameters :
["contextInfo" :
["clientId": "1000000", "orgId": "1000001",
"warehouseId": "1000002", "roleId": "0"],
"userName": "hanoiaUser", "password": "hanoiaUser"]
Request :
Alamofire.request(url!, method: .post, parameters: params).responseJSON { (response) in
print(response)
}
Error response :
FAILURE: responseSerializationFailed(Alamofire.AFError.ResponseSerializationFailureReason.jsonSerializationFailed(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 0." UserInfo={NSDebugDescription=Invalid value around character 0.}))
Why am i getting this error? and how to solve it ?
Edit : i'm tried with POSTMAN and it return response :
Content-Type : application/json
Body : raw - json
{
"contextInfo" : {
"clientId":1000000,
"orgId": 1000001,
"warehouseId": 1000002,
"roleId": 0
},
"userName": "hanoiaUser",
"password": "hanoiaUser"
}
RESPONSE :
{
"success": true,
"data": [
{
"userId": 1000003,
"userName": "hanoiaUser",
"token": "b7e804d25065e5c3ac97d765180b7986"
}
],
"error": null
}
Ok, finally I solved the problem
Here's new request :
Alamofire.request(url!, method: .post,encoding : JSONEncoding.default, headers: headers, parameters: params).responseJSON { (response) in
print(response)
}
With Headers :
let headers = [
"Content-Type": "application/json"
]
Set the request header like :
request.allHTTPHeaderFields = ["Content-Type":"application/json"]
I sent this request to hyperledger's REST API:
$ curl -X POST --header "Content-Type: application/json" -d '{ "jsonrpc": "2.0", "method": "deploy", "params": { "type": 1, "chaincodeID":{ "path":"github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" }, "ctorMsg": { "args":["init", "a", "1000", "b", "2000"] } }, "id": 1 }' localhost:7050/chaincode
and this is the error message I got in return:
{"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Error unmarshalling chaincode request payload: illegal base64 data at input byte 0"},"id":null}
I then added debug log in rest_api.go to check whatever is received by the peer
and got this log:
16:03:46.323 [rest] ProcessChaincode -> DEBU 027 reqBody = { "jsonrpc": "2.0", "method": "deploy", "params": { "type": 1, "chaincodeID":{ "path":"github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02" }, "ctorMsg": { "args":["init", "a", "1000", "b", "2000"] } }, "id": 1 }
16:03:46.331 [rest] ProcessChaincode -> ERRO 028 Error unmarshalling chaincode request payload: illegal base64 data at input byte 0
The received message seems to match with the definition of "rpcRequest", "ChaincodeSpec", and "ChaincodeInput", I don't understand why it keeps throwing unmarshalling error to me...