Page 2 of 3

Re: JSONWEBSRV.sqlrpgle

Posted: Fri Mar 01, 2024 5:16 pm
by freelance
This is what we attempting to use, to post our products on it -

https://seller-us.tiktok.com/product/manage

Re: JSONWEBSRV.sqlrpgle

Posted: Fri Mar 01, 2024 9:03 pm
by jonboy49
That URL doesn't help. It requires that you sign in and I do not have a TikTok developer Id.

I am willing to try and help but please read my response and answer the questions in a meaningful way.

Assuming that the TikTok API you referenced is similar to the one I listed then you here's the basic setup you need.

1) Use HTTPAPI (or SQL or whatever) to call the required API and either pass it the file content (2 below) _OR_ pass it a URL where it can find the file (3 below).

2) If you choose to pass the file itself you will probably need to get into Base64 encoding etc. depending on the APIs requirements. Since you haven't given us the API details I can tell you what you will need.

3) If you choose to pass a URL (the simplest option) then you will have to find a secure way to open up your IBM i to the internet. This is a complex question with many variables. Configuring Apache to allow the download is trivial. Securing it so that you have not opened the system to harm is waaaayyyyyy more complex and you need expert advice. One possible alternative to opening your system is to use a third-party file server - or indeed create such a server elsewhere on your network,

Re: JSONWEBSRV.sqlrpgle

Posted: Fri Mar 01, 2024 9:44 pm
by freelance
yes

Re: JSONWEBSRV.sqlrpgle

Posted: Fri Mar 01, 2024 9:48 pm
by freelance
In this case, I had to switchover to HTTPAPI. For which I wrote the rpg pgm taken from Example7.

On pgm execution in debug mode.. did get this run-time error as follows -

MSG = 'open(): Resource busy. '

With RC = -1

EVAL tempFile
TEMPFILE =
....5...10...15
1 '/tmp/QACXXP5CXD

For code segment –
59 // post the results to the web server
60
61 rc = http_url_post_stmf('https://seller-us.tiktok.com/product'
62 + '/manage'
63 : tempFile
64 : '/tmp/makejson1.json'
65 : HTTP_TIMEOUT
66 : HTTP_USERAGENT
67 : ContentType );

69 if (rc <> 1); <-- -1
70 msg = http_error();
71 dsply msg; <-- MSG = 'open(): Resource busy. '
72 return;
73 endif;

Re: JSONWEBSRV.sqlrpgle

Posted: Fri Mar 01, 2024 10:01 pm
by freelance
To try it out, we could change that titok link to your provided tiktok link, to test the pgm.

Re: JSONWEBSRV.sqlrpgle

Posted: Fri Mar 01, 2024 10:54 pm
by jonboy49
freelance wrote: Fri Mar 01, 2024 9:44 pmyes
Meaning that the REST service you are using is similar to the one I referenced?

If not ??

Re: JSONWEBSRV.sqlrpgle

Posted: Fri Mar 01, 2024 11:19 pm
by jonboy49
freelance wrote: Fri Mar 01, 2024 9:48 pm In this case, I had to switchover to HTTPAPI. For which I wrote the rpg pgm taken from Example7.
Example 7 assumes that there is a web site at the other end which is expecting multi-part form data and that one of the inputs is a file. It has no notion of authentication. It is also highly unlikely that the TikTok API works like that.
61 rc = http_url_post_stmf('https://seller-us.tiktok.com/product'
62 + '/manage'
63 : tempFile
64 : '/tmp/makejson1.json'
65 : HTTP_TIMEOUT
66 : HTTP_USERAGENT
67 : ContentType );
Did you just make this URL up? I cannot find any such URL in the TikTok API set. Please supply a reachable _documentation_ URL similar to this one: https://business-api.tiktok.com/portal/ ... 7433456642

I can pretty much guarantee that the TikTok APIs do not work the way your code is written, but unless you show me the definition for the actual API you need to use I can't help.

To put it bluntly - you need to learn the basics of interacting with REST APIs and stop just guessing and trying to find stuff that you can modify. Once you learn the basics then you can apply that knowledge to the TikTok APIs. They don't look that complicated - although the documentation is not that good.

JSON2WEB.rpgle (HTTPAPI)

Posted: Sun Mar 03, 2024 4:45 pm
by freelance
Hi there, I am already showing you the API defination/segment. See our HTTPAPI forum message as on Fri Mar 01, 2024 4:48 pm

We are trying to post our AS/400-IFS xxx.JSON file data onto 3rd party website i.e. Titok seller center ('https://seller-us.tiktok.com/product/manage').
That one requires us to login with our Tiktok acc id to access Tiktok shop acc and access the seller center postings page.

So, typically we would need to accommodate API keys i.e. Oauth2 (public & private keys) in our HTTPAPI defination/code segment.
Postman is a manual option we got. Or would GETURI be a good option in this scenario ?

SINCE, jsonwebsrv routine was not suitable; we switched over to HTTPAPI Example7 and made our changes accordingly in there.

Now, would want you to review that API defination/segment that we have put up.

And pl respond ASAP with your thoughts. Thanks

Re: JSONWEBSRV.sqlrpgle

Posted: Sun Mar 03, 2024 7:01 pm
by jonboy49
jonboy49 wrote: Fri Mar 01, 2024 11:19 pm Did you just make this URL up? I cannot find any such URL in the TikTok API set. Please supply a reachable _documentation_ URL similar to this one: https://business-api.tiktok.com/portal/ ... 7433456642

I can pretty much guarantee that the TikTok APIs do not work the way your code is written, but unless you show me the definition for the actual API you need to use I can't help.
I repeat what I said before - Look at the page I referenced - THAT is an API definition and is NOTHING like the code you posted.

We can't help you if you don't help yourself by supplying the _original_ docs! If you can't provide a public link then print the web page that describes the API to pdf and then upload that.

JSON2WEB.rpgle

Posted: Sun Mar 03, 2024 8:05 pm
by freelance
What do mean by supplying the _original_ docs! ? Original docs are HTTPAPI-Example7

We are providing IFS path to our .JSON file data in the HTTPAPI code segment.

Now, we need to accommodate API keys. Any additional provision for that ?