Hello Dear Coders,
I want to post request with my web api and this way my web site can create an order.
When i tried this method in kodular it is worked! but not for all datas.
Here is my kodular blocks;
Web url format is: https://example.com/ /wp-json/wc/v3/orders?consumer_key=ck_xxxx&consumer_secret=cs
With above blocks i can succesfully post with main array which are “payment_method”,“set_paid”,“payment_method_title” but i can not post first name, last name under the “billing” array. How can i run this ?,
The api intruction is in below,
1 Like
TimAi2
(metricrat)
March 24, 2021, 5:10pm
2
Try PostText with a string of parameters:
for example
.PostText text > join > firstname=tttt&lastname=zzz&city=yyy
(note no question mark needed for the first parameter when using PostText)
2 Likes
Hello they are sub strings i have already try this it is not working what is your suggestion to run sub strings ?
Rogerio_Rios
(Professional Support)
March 24, 2021, 5:27pm
4
Create your POST parameters with Join .
Can you explain more detaily with block ?
TimAi2
(metricrat)
March 24, 2021, 8:19pm
6
If I must…
If as you say, these are substrings, you may need to either:
add an “&” to the first item parameter
or
Place all of your parameters in your posttext join block
1 Like
I have tried your method posting funciton is working but sub string is data first name is not posted.
Main string is “billing”
and sub string is “first-name” and this is what i tried;
TimAi2
(metricrat)
March 24, 2021, 9:12pm
9
you didn’t add a value to the billing parameter…
yes i am trying to add for first name value but first name string is under string to billing data.
In this block remove & and try
It will print as first name=text box.text
sorry, did not worked. and it does not make sense because in my json data both under the billing object and shipping object includes “first_name” string.
TimAi2
(metricrat)
March 24, 2021, 10:53pm
13
I am sorry, I have not being paying attention! You probably need to manually create a json string for your “substring”. Back in a minute with an example here…
Like this ?
You may need to post all your parameters in a json string…
1 Like
Taifun
March 25, 2021, 12:14am
14
you also have to set the Content-Type in the request header…
your Content-Type is application/json
see an example here App Inventor Tutorials and Examples: Dropbox | Pura Vida Apps
and you have to put together your json string manually as @TimAi2 already mentioned…
Taifun
2 Likes
Hello Dear All,
I have tried all your methods what you told me but never worked. What is my fault ?
Here is my blocks.
Here is documantetion about api;
TimAi2
(metricrat)
March 25, 2021, 9:05am
16
Remove the single quotes from the beginning and end of your JSON string?
'{
> {
and }'
> }
Try billing outside of the JSON with an equals sign ?
Hello,
did not worked. As i said before, all main object i can post but sub strings i could not posted.
Taifun
March 26, 2021, 9:55pm
18
follow @TimAi2 's advice…
and post a screenshot of your complete JSON string… where are your substrings?
also use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools
and then you might want to verify your JSON string in an online tools like https://jsonlint.com/
in the end your JSON string must look like exactly as in the example
https://kodular-community-uploads.s3.dualstack.eu-west-1.amazonaws.com/optimized/3X/7/9/799527aabc424f08e99231be81fe5b9f039dcb1d_2_1035x345.png
Taifun
you also have to set the Content-Type in the request header…
your Content-Type is application/json
see an example here https://puravidaapps.com/dropbox.php
and you have to put together your json string manually as @TimAi2 already mentioned…
Taifun
Hi Taifun
Please , can you tell me how can i setup but not for header but for the Body ? Is it Possible to setup not the header but the Body with by example ==> Content-Type ?
Rogerio_Rios
(Professional Support)
October 21, 2021, 10:54am
20
1 Like