POST /post HTTP/1.1
Content-Type: application/json
X-Rapidapi-Host: theblock.ppapi.com
X-Rapidapi-Key: [YOUR API KEY]
Host: theblock.ppapi.com
Content-Length: 181
{
"post_language_id": "22",
"post_title": "My first post title",
"post_content": "This is an example post. The post can be between three and 1000 characters long."
}
MYDATA (aade.gr - gsis) my Digital Accounting and Tax Application SendInvoices Well the Greek Members already know what mean that for them (if had Invoice Apps, ERPs.. etc)... The other guys can read here what means and why exactly needed for their ERPs, CLOUD ERP softwares gonna sell to...
Let me make my question clear a little bit. I want to write the code in B4a, using the httpJob. None of the following works. All returned with an error that post_language_id, post_title and post_content parameters are missing.
B4X:
Dim j as httpJob
j.initialize("",me)
Dim url as string = "https://theblock.ppapi.com/example?post_language_id=22&post_title=My first post title&post_content=This is an example post. The post can be between three and 1000 characters long."
j.postString(url,"")
j.getRequest.SetHeader("X-Rapidapi-Host","theblock.ppapi.com")
j.getRequest.SetHeader("X-Rapidapi-Key","YOUR API KEY")
B4X:
Dim j as httpJob
j.initialize("",me)
Dim url as string = "https://theblock.ppapi.com/example"
j.postString(url,"post_language_id=22&post_title=My first post title&post_content=This is an example post. The post can be between three and 1000 characters long.")
j.getRequest.SetHeader("X-Rapidapi-Host","theblock.ppapi.com")
j.getRequest.SetHeader("X-Rapidapi-Key","YOUR API KEY")
B4X:
Dim j as httpJob
j.initialize("",me)
Dim url as string = "https://theblock.ppapi.com/example"
j.postmultipart(url,CreateMap("post_language_id":22,"post_title":"My first post title","post_content":"This is an example post. The post can be between three and 1000 characters long."),null)
j.getRequest.SetHeader("X-Rapidapi-Host","theblock.ppapi.com")
j.getRequest.SetHeader("X-Rapidapi-Key","YOUR API KEY")
First of all you must generate the json right search how...
Then you must send it... I think is the same with b4j...
B4X:
Dim JSON As JSONGenerator
JSON.Initialize(Map1)
Dim data As String = JSON.ToPrettyString(1)
Dim Job As HttpJob
Job.Initialize("Job1",Me)
Job.Username="..."
Job.Password="..."
Job.PostString("https://blah.com/name" , data )
Job.GetRequest.SetContentType("application/json")
First of all you must generate the json right search how...
Then you must send it... I think is the same with b4j...
B4X:
Dim JSON As JSONGenerator
JSON.Initialize(Map1)
Dim data As String = JSON.ToPrettyString(1)
Dim Job As HttpJob
Job.Initialize("Job1",Me)
Job.Username="..."
Job.Password="..."
Job.PostString("https://blah.com/name" , data )
Job.GetRequest.SetContentType("application/json")
Still return the same error response (parameters missing) with this:
B4X:
Dim j as httpJob
j.initialize("",me)
Dim url as string = "https://theblock.ppapi.com/example"
Dim m as map = CreateMap("post_language_id":22,"post_title":"My first post title","post_content":"This is an example post. The post can be between three and 1000 characters long.")
Dim json as JSONGenerator
j.postString(url,json.ToPrettyString(1))
j.getRequest.SetHeader("X-Rapidapi-Host","theblock.ppapi.com")
j.getRequest.SetHeader("X-Rapidapi-Key","YOUR API KEY")
j.getRequest.SetContentType("application/json")
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r
\"post_language_id\": \"22\",\r
\"post_title\": \"My first post title\",\r
\"post_content\": \"This is an example post. The post can be between three and 1000 characters long.\"\r
}");
Request request = new Request.Builder()
.url("https://theblock.ppapi.com/example")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("x-rapidapi-host", "https://theblock.ppapi.com")
.addHeader("x-rapidapi-key", YOUR API KEY)
.build();
Response response = client.newCall(request).execute();
Solved! Thanks so much! I had the Json initialized in previous codes so the code runs with no error put it doesn't send the right string to http job. It works now! You saved my day! <3