-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
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
Labels
No labels