Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find conversation error recently started (last 2 days) #35

Open
ikbenben opened this issue Jul 14, 2017 · 0 comments
Open

Could not find conversation error recently started (last 2 days) #35

ikbenben opened this issue Jul 14, 2017 · 0 comments

Comments

@ikbenben
Copy link

Hi There,

we have some code that looks up conversations between 2 users. It does this by getting the conversation list of one of the users and then iterating over the result until it finds a conversation that includes the other user.

The code is as follows:

def get_conversation(user1, user2)

  conversation = nil

  layer_client = get_layer_client(user1)
  client_conversations = Layer::Conversation.all(layer_client)
  puts "client_conversations: #{client_conversations.inspect}"
  
  matches = client_conversations.select { |c|
    puts "iter conversation: #{c.inspect}"
    c.attributes["participants"].include? user2.id.to_s
  }

  puts "matches: #{matches.inspect}"
  if matches.count > 0
    conversation = matches[0]
  end
end

When this method is called, we receive a 'not_found' error

{
  "code": 102,
  "id": "not_found",
  "message": "A Conversation with the specified identifier could not be found.",
  "url": "https://developer.layer.com/docs/client/rest#not_found"
}

Before running the above code, we created a conversation and then made sure it exists using curl commands as below:

Create Conversation

curl -X POST \
      -H 'Accept: application/vnd.layer+json; version=1.0' \
      -H 'Authorization: Bearer KOO2lnsIwsRrpdRNPcbx2wQ7wnyevvNaI2QN5ay4SUhFzJdQ' \
      -H 'Content-Type: application/json' \
      https://api.layer.com/apps/4d832b8c-7656-11e5-b603-70c100000104/conversations \
      -d '{"participants":["2","3"],"distinct":false,"metadata":{"background_color":"#3c3c3c"}}'

Fetch Conversation

curl -X GET \
     -H 'Accept: application/vnd.layer+json; version=1.0' \
     -H 'Authorization: Bearer KOO2lnsIwsRrpdRNPcbx2wQ7wnyevvNaI2QN5ay4SUhFzJdQ' \
     -H 'Content-Type: application/json' \
     https://api.layer.com/apps/4d832b8c-7656-11e5-b603-70c100000104/users/2/conversations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant