- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2024 10:32 AM
Error: Error Code: 1 Error Message: Method failed: (/api/v4/users/awe2g4q/) with code: 400
*** Script: Method failed: (/api/v4/users/awe2g4q/) with code: 400
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 04:21 AM
Hi Suhyeon,
The error is HTTP 400 Bad Request, happens as the URL is misinterpreted/missing data. Did you check if Content-Type, Authorization as headers?
I see as per Wrike API Docs - , "Authorization: bearer eyJ0dCI6InAiLCJhbGciOiJIUzI1NiIsInR2IjoiMSJ9.eyJkIjoie1wiYVwiOjIyMzMwMDEzLFwiaVwiOjIyLFwiY1wiOjEwMDUsXCJ2XCI6XCJcIixcInVcIjozNyxcInJcIjpcIlVTXCIsXCJzXCI6W1wiTlwiLFwiSVwiLFwiV1wiLFwiRlwiLFwiS1wiLFwiVVwiLFwiQ1wiLFwiQVwiLFwiTFwiLFwiUFwiLFwiQlwiLFwiRFwiXSxcInpcIjpbXSxcInRcIjoxNzI2NTYzMDgxMDAwfSIsImV4cCI6MTcyNjU2MzA4MSwiaWF0IjoxNzI2NTU5NDgxfQ.7eR6FV8Vank0NvbVQ1Zx5x8YIPKZMlXUKsW7lGLva2k' is available for Header usage.
Secondly, incase you are getting user information using GET, try sm.setStringParameterNoEscape('user_id', 'awe2g4q');
var sm = new sn_ws.RESTMessageV2('Wrike API', 'CONTACTS');
//assuming CONTACTS is GET method and Wrike API can have the parent URL <'https://wrike.com/API/V4/USERS'>
sm.setStringParameterNoEscape('user_id', 'awe2g4q'); // User ID
var response = sm.execute();
var responseBody = response.getBody();
var status = response.getStatusCode();
gs.info(responseBody);
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 04:25 AM
Hi @Suhyeon Lee
Here's a revised version of your code:
var sm = new sn_ws.RESTMessageV2('Wrike API', 'CONTACTS');
sm.setHttpMethod('GET');
sm.setEndpoint('https://www.wrike.com/api/v4/contacts/AWE2G4Q');
sm.setRequestHeader('Authorization', 'Bearer your_api_key_or_oauth_token');
var response = sm.execute();
var responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();
var status = response.getStatusCode();
gs.info('Status Code: ' + status);
gs.info('Response Body: ' + responseBody);
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
Regards
Shaqeel
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 04:21 AM
Hi Suhyeon,
The error is HTTP 400 Bad Request, happens as the URL is misinterpreted/missing data. Did you check if Content-Type, Authorization as headers?
I see as per Wrike API Docs - , "Authorization: bearer eyJ0dCI6InAiLCJhbGciOiJIUzI1NiIsInR2IjoiMSJ9.eyJkIjoie1wiYVwiOjIyMzMwMDEzLFwiaVwiOjIyLFwiY1wiOjEwMDUsXCJ2XCI6XCJcIixcInVcIjozNyxcInJcIjpcIlVTXCIsXCJzXCI6W1wiTlwiLFwiSVwiLFwiV1wiLFwiRlwiLFwiS1wiLFwiVVwiLFwiQ1wiLFwiQVwiLFwiTFwiLFwiUFwiLFwiQlwiLFwiRFwiXSxcInpcIjpbXSxcInRcIjoxNzI2NTYzMDgxMDAwfSIsImV4cCI6MTcyNjU2MzA4MSwiaWF0IjoxNzI2NTU5NDgxfQ.7eR6FV8Vank0NvbVQ1Zx5x8YIPKZMlXUKsW7lGLva2k' is available for Header usage.
Secondly, incase you are getting user information using GET, try sm.setStringParameterNoEscape('user_id', 'awe2g4q');
var sm = new sn_ws.RESTMessageV2('Wrike API', 'CONTACTS');
//assuming CONTACTS is GET method and Wrike API can have the parent URL <'https://wrike.com/API/V4/USERS'>
sm.setStringParameterNoEscape('user_id', 'awe2g4q'); // User ID
var response = sm.execute();
var responseBody = response.getBody();
var status = response.getStatusCode();
gs.info(responseBody);
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2024 04:25 AM
Hi @Suhyeon Lee
Here's a revised version of your code:
var sm = new sn_ws.RESTMessageV2('Wrike API', 'CONTACTS');
sm.setHttpMethod('GET');
sm.setEndpoint('https://www.wrike.com/api/v4/contacts/AWE2G4Q');
sm.setRequestHeader('Authorization', 'Bearer your_api_key_or_oauth_token');
var response = sm.execute();
var responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();
var status = response.getStatusCode();
gs.info('Status Code: ' + status);
gs.info('Response Body: ' + responseBody);
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.
Regards
Shaqeel
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2024 12:09 AM
Hi @Suhyeon Lee
Thanks a lot. 🙂
***********************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
***********************************************************************************************************************
Regards
Shaqeel