Skip to content

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

@ikbenben

Description

@ikbenben

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions