You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the details like directory, file, body, sessionID, sourceEncoding. targetEncoding, last Chunk, forceOverwite Problem # 1: You will be wondering what should we add in sessionID as the field is mandatory.
As per the API doc and API behaviour Please note that your first request will fail because you haven't been assigned a sessionID. If you don't have a sessionID in your request, then the server will assign you one and send it as a response. Please attach this sessionID to every subsequent request as a query parameter. This sessionID is linked to a particular file, so you must use it for the duration of the upload. If you lose it, then the file will be inaccessible via this API until your session timesout in five minutes.
as shown in above screenshot.
WE SHOULD MAKE SESSION ID FIELD NOT MANDATORY. So that we can run the API for the first time to get the session ID.
4. Try the same URL in some third party tool like Insomnia and do not add the session ID in the URL. Also add the body content to write into the FIle. The request will give u a session ID back and it will create an empty file if the file does not exist.
For example: try to create the file APIFILE under /u/zowe/testing https://server:port/zss/api/v1/unixfile/contents/%2Fu%2Fzowe%2Ftesting/APIFILE?sourceEncoding=UTF-8&targetEncoding=UTF-8&lastChunk=false&forceOverwrite=true
5. Now use this session ID in the API catalog and try the API as we tried in Step 3. It will work.
6. Go in editor and open the file. Problem # 2: You will not see the content that you were trying to add into the file but you will find the below mentioned function with return code getting added to the file, each time we try to run the API.
int main() {
return 0;
}
The text was updated successfully, but these errors were encountered:
You can upload the file in chunks or you can treat the entire file as a single chunk. There is a query parameter that you must attach, lastChunk, that controls this behavior.
If you are using this for file editing, then lastChunk=true is sufficient. If you are using this for file uploading, then lastChunk=false is useful, as it will append the body of each previous request to the file until lastChunk=true is received.
You are being expected to provide a base-64 encoded body with every PUT request to /contents.
Problems
(1) The field should be made not mandatory so that you can use tools like above. It is exactly as you stated; the first request will fail.
(2) This is the intended behavior since you are using lastChunk=false. It will keep appending the body of the request to the file until it times out or you use lastChunk=true. I think the code snippet, int main() { return 0; }, is coming from whatever tool you are using to send the request. It is probably aW50IG1haW4oKSB7CiAgcmV0dXJuIDA7Cn0= being sent each time you send the request.
@jordanfilteau1995 regarding (2): Yes I have intentionally set the lastChunk=false to add the content at the end of the file each time I send the API request.
I have only used the Insomnia tool to run the API for the very first time and get the session ID. Once I had the session ID, I used the API from API catalog, to add the content to the file. But it was adding int main() { return 0; } instead of aW50IG1haW4oKSB7CiAgcmV0dXJuIDA7Cn0=
Then I opened the Editor and tried to check the response when I open the File, The response had "aW50IG1haW4oKSB7CiAgcmV0dXJuIDA7Cn0=" in it is shown as int main() { return 0; } in editor.
I tried to decode aW50IG1haW4oKSB7CiAgcmV0dXJuIDA7Cn0= and it gets decodes to int main() { return 0; }
SO IT SEEMS LIKE WORKING AS EXPECTED
Steps to reproduce:
Problem # 1: You will be wondering what should we add in sessionID as the field is mandatory.
As per the API doc and API behaviour
Please note that your first request will fail because you haven't been assigned a sessionID. If you don't have a sessionID in your request, then the server will assign you one and send it as a response. Please attach this sessionID to every subsequent request as a query parameter. This sessionID is linked to a particular file, so you must use it for the duration of the upload. If you lose it, then the file will be inaccessible via this API until your session timesout in five minutes.
as shown in above screenshot.
WE SHOULD MAKE
SESSION ID
FIELD NOT MANDATORY. So that we can run the API for the first time to get the session ID.4. Try the same URL in some third party tool like Insomnia and do not add the session ID in the URL. Also add the body content to write into the FIle. The request will give u a session ID back and it will create an empty file if the file does not exist.
For example: try to create the file APIFILE under /u/zowe/testing
https://server:port/zss/api/v1/unixfile/contents/%2Fu%2Fzowe%2Ftesting/APIFILE?sourceEncoding=UTF-8&targetEncoding=UTF-8&lastChunk=false&forceOverwrite=true
5. Now use this session ID in the API catalog and try the API as we tried in Step 3. It will work.
6. Go in editor and open the file.
Problem # 2: You will not see the content that you were trying to add into the file but you will find the below mentioned function with return code getting added to the file, each time we try to run the API.
The text was updated successfully, but these errors were encountered: