NodeJS - Profile Request - Request failed with status code 404

Hi All,

Any help to solve this mystery for me is greatly Appreciated. I am new to NodeJS scripting and developing a Line Bot for my own personal use. I have scripted my own debug script to output to the console log the values I want and later manipulate based on what the outcome is.

I have followed the example here -> https://developers.line.biz/en/reference/messaging-api/#get-profile to get the profile data of the user in question. However recently I have noticed that when outputting to my console, alot of Request Failed with status code 404 errors are appearing when users write their messages.

I am using the heroku platform and when i restart the app, it would initially work and I would get the profile name output as intended, but after that all other attempts have failed with the status code.

Is there something wrong with the NodeJS code above? Or is there a certain request limit to Line that can only request profiles of certain users over a certain period of time.

FYI I am only using the Free Plan of the Line Developers Account.

Thanks in Advance.

  • 0
  • 4
  • 6307
  • twitter facebook

I have solved my own issue. By replacing .getProfile with .getGroupMemberProfile seems to have worked. :)

  • 0

So I have investigated further into this and trying this code now - https://developers.line.biz/en/reference/messaging-api/#get-group-member-profile

I will be modifying my value of .getProfile to .getGroupMemberProfile and see if this fixes my problem.

  • 0

Hi Shoya,

Sure No Problems, Please see below:


 function debug_check(e) {
 45         var d = new Date(e.timestamp);
 46         console.log("Event Time Stamp:" + d);
 47         console.log("Event Source User ID:"+ e.source.userId);
 48         client.getProfile(e.source.userId).then((profile) => {
 49                  console.log("Profile Display Name:"+ profile.displayName);
 50                  //console.log("Profile User ID:"+ profile.userId);
 51                  //console.log("Profile Picture URL:"+ profile.pictureUrl);
 52                  //console.log("Profile Status Message:"+ profile.statusMessage);
 53          })
 54           .catch((err) => {
 55                  console.log(err.message);
 56          });
 57         //console.log("Event Source Room ID:"+ e.source.roomId);
 58         console.log("Event Source Group ID:"+ e.source.groupId);
 59         console.log("Event Type:"+ e.type);
 60         console.log("Event Message ID:"+ e.message.id);
 61         console.log("Event Message Type:"+ e.message.type);
 62 }

Output from console log - Working Reply With Profile Name (I have modified the User ID, Group ID)

2018-11-28T02:06:33.959943+00:00 app[web.1]: Event Time Stamp:Wed Nov 28 2018 02:06:33 GMT+0000 (Coordinated Universal Time)
2018-11-28T02:06:33.960059+00:00 app[web.1]: Event Source User ID:11111111111111111111
2018-11-28T02:06:33.962477+00:00 app[web.1]: Event Source Group ID:1111111111111111111
2018-11-28T02:06:33.962939+00:00 app[web.1]: Event Type:message
2018-11-28T02:06:33.963006+00:00 app[web.1]: Event Message ID:11111111111
2018-11-28T02:06:33.963283+00:00 app[web.1]: Event Message Type:text
2018-11-28T02:06:33.963353+00:00 app[web.1]: In:I like pie
2018-11-28T02:06:33.963476+00:00 app[web.1]: Decipher:i,like,pie
2018-11-28T02:06:34.357791+00:00 app[web.1]: Profile Display Name:HarK UTC+8

Out from Console Log - Not working Reply with Profile Name

2018-11-28T02:10:10.846876+00:00 app[web.1]: Event Time Stamp:Wed Nov 28 2018 02:10:10 GMT+0000 (Coordinated Universal Time)
2018-11-28T02:10:10.846902+00:00 app[web.1]: Event Source User ID:22222222222222222
2018-11-28T02:10:10.846996+00:00 app[web.1]: Event Source Group ID:11111111111111111
2018-11-28T02:10:10.847004+00:00 app[web.1]: Event Type:message
2018-11-28T02:10:10.847054+00:00 app[web.1]: Event Message ID:1111111111111111
2018-11-28T02:10:10.847060+00:00 app[web.1]: Event Message Type:text
2018-11-28T02:10:10.847112+00:00 app[web.1]: In:I like pie too hark
2018-11-28T02:10:10.847162+00:00 app[web.1]: Decipher:i,like,pie,too,hark
2018-11-28T02:10:11.040747+00:00 app[web.1]: Request failed with status code 404

From further testing I can see that the profile request only works if it is "my account" But if I try to retrieve anyone else's account in the "Group Chat" i will get a 404 error. Very weird.

  • 0

Can I show your part of code?

  • 0
Are you sure? question.vm